ParticlePreset emitter[,preset]
Parameters
|
emitter - CPU or GPU particle emitter entity preset (optional) - effect to load 1: fire (default) 2: smoke 3: rain 4: sparks 5: magic 6: dust |
Description
|
Loads a ready-made effect into an emitter. This is the fastest way to get something on screen. Each preset sets the whole motion and appearance block in one go - emission rate, lifetime, emitter shape, velocity and variation, gravity, drag, start and end colour, sizes, rotation, render mode and blend mode - so you can create an emitter, call ParticlePreset, and already have a believable campfire or rainstorm. Fire and magic use additive blending and look best against a dark scene. Rain uses velocity-stretched billboards so each drop becomes a streak. Sparks deliberately set the emission rate to 0, because they are meant to be fired as bursts with EmitParticles when something explodes. Smoke and dust use ordinary alpha blending and slow, drifting motion. Treat a preset as a starting point: call it first, then override just the settings your effect needs. A torch is usually preset 1 with a smaller ParticleSize; a boss aura is usually preset 5 with a different ParticleColor. Gotcha: a preset is a reset, not a merge. It clears every live particle, un-pauses the emitter, switches back to world space, turns sorting off, disables particle collision, clears any attractor, and drops the sprite-sheet animation back to a single frame. Anything you configured before the call is lost, so always apply the preset first and tweak afterwards. The maximum particle count and the emitter's texture are not touched by a preset - those stay as you set them with CreateParticleEmitter and EntityTexture. For the full story, see the Particles guide. Requires Extended mode. See also: CreateParticleEmitter, ParticleColor, ParticleSize, ParticleRenderMode, EmitParticles. |
Example
; ParticlePreset Example ; ---------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-6 CameraClsColor camera,8,12,24 floor=CreatePlane() EntityColor floor,30,34,44 ; Preset names for the overlay Dim preset_name$(6) preset_name$(1)="1 fire" preset_name$(2)="2 smoke" preset_name$(3)="3 rain" preset_name$(4)="4 sparks" preset_name$(5)="5 magic" preset_name$(6)="6 dust" ; One emitter is enough - a preset configures the whole effect emitter=CreateParticleEmitter(1200) PositionEntity emitter,0,0.25,0 preset=1 ParticlePreset emitter,1 While Not KeyDown(1) ; Keys 1-6 apply a complete ready-made effect For choice=1 To 6 If KeyHit(1+choice) preset=choice ParticlePreset emitter,preset ; Rain works best falling from above; the rest sit near the ground If preset=3 Then PositionEntity emitter,0,5,0 Else PositionEntity emitter,0,0.25,0 If preset=4 Then EmitParticles emitter,160 EndIf Next If KeyHit(57) Then EmitParticles emitter,120 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 ; UpdateWorld also advances the particle simulation UpdateWorld RenderWorld Text 0,0,"Arrow keys: move camera 1-6: preset Space: burst Esc: exit" Text 0,20,"ParticlePreset emitter,"+preset+" ("+preset_name$(preset)+")" Text 0,40,"Live particles: "+CountParticles(emitter) Flip Wend End
Index