Particle emitter object

Particle emitters are used to create various realtime particle effects, such as snow, rain or smoke. Particle emitters are always owned by entities or actors. You create a particle emittor by calling the CreateParticleEmitter() method of an entity or of an actor. You can then query the particle emitter using the ParticleEmitter property.


Methods

Operations
SetBorder Sets the rectangular area on screens to contain the particles.
SetBorderThickness Sets the thickness of the border rectangle defined by SetBorder() method.
AddSprite Adds a sprite to be used for particle representation.
RemoveSprite Removes a specified sprite from the list.
Start Executes the particle generation.
Stop Shuts down the particle emitter.
Pause Pauses the particle generation.
Resume Resumes the particle generation.
AddGlobalForce Adds a global force which will affect all particles equally.
AddPointForce Adds a point force which will affect the particles depending on their distance from the force origin.
RemoveForce Removes a force with the given name.

Attributes

Type (read only) Returns always "particle-emitter"
X The X position of the emitter rectangle
Y The Y position of the emitter rectangle
Width The width of the emitter rectangle
Height The height of the emitter rectangle
Scale1 The lower value of the scale range for particles
Scale2 The upper value of the scale range for particles
ScaleZBased Specifies if the scale is dependent on the particle's depth
Velocity1 The lower value of the velocity range for particles
Velocity2 The upper value of the velocity range for particles
VelocityZBased Specifies if the velocity is dependent on the particle's depth
LifeTime1 The lower value of the life time range for particles (in milliseconds)
LifeTime2 The upper value of the life time range for particles (in milliseconds)
LifeTimeZBased Specifies if the life time is dependent on the particle's depth
Angle1 The lower value of the initial direction range for particles (in degrees, 0 degrees = up)
Angle2 The upper value of the initial direction range for particles (in degrees, 0 degrees = up)
AngVelocity1 The lower value of the angular velocity (rotation speed) for particles
AngVelocity2 The upper value of the angular velocity (rotation speed) for particles
Rotation1 The lower value of the initial rotation range for particles (in degrees, 0 degrees = up)
Rotation2 The upper value of the initial rotation range for particles (in degrees, 0 degrees = up)
Alpha1 The lower value of the alpha transparency range for particles (0 to 255)
Alpha2 The upper value of the alpha transparency range for particles (0 to 255)
AlphaTimeBased Specifies if the actual alpha value of the particle changes with time
GrowthRate1 The lower value of the growth/shrink rate range for particles (in percent)
GrowthRate2 The upper value of the growth/shrink rate range for particles (in percent)
ExponentialGrowth Specifies if the particles grow/shrink exponentially (the bigger they are, the faster they grow) or linear
UseRegion If set to true, the particles are only visible when they are inside a region (only works for particle emitters owned by region entities)
MaxParticles Specifies the maximum number of particles to be ever generated
NumLiveParticles (read only) Returns the number of currently active particles on screen
GenerationInterval The time interval in which new particles are being generated (in milliseconds)
GenerationAmount Specifies the amount of particles to be generated for each GenerationInterval
MaxBatches Specifies the maximum number of particle batches to be generated (0=no limit)
FadeInTime The time it takes the particles to fade in when they are generated (in milliseconds)
FadeOutTime The time it takes the particles to fade out when they are dying (in milliseconds)
BlendMode Specifies how the particles' images are blended with the background colors; 0...normal mode, 1...additive blending, 2...subtractive blending
EmitEvent The name of an event which is triggered in the emitter's owner object whenever a new batch of particles is generated.

SetBorder(X, Y, Width, Height)

Sets the rectangular area on screens to contain the particles.

Parameters

X
The X position of the border rectangle
Y
The Y position of the border rectangle
Width
The width of the border rectangle
Height
The height of the border rectangle

Return value

Returns true if the method succeeded.

Remarks

The border rectangle limits the area the particles can exist in. Once the particle hits the border rectangle, it dies. You can specify the thickness of the border using the SetBorderThickness() method. Call this method without parameters to disable border.


SetBorderThickness(Left, Right, Top, Bottom)

Sets the thickness of the border rectangle defined by SetBorder() method.

Parameters

Left
Specifies the thickness of the left edge of the border rectangle
Right
Specifies the thickness of the right edge of the border rectangle
Top
Specifies the thickness of the top edge of the border rectangle
Bottom
Specifies the thickness of the bottom edge of the border rectangle

Return value

Returns true if the method succeeded.


AddSprite(Filename)

Adds a sprite to be used for particle representation.

Parameters

Filename
The filename of a sprite to be used

Return value

Returns true if the method succeeded.

Remarks

You can add as many sprites as you want. When a new particle is generated, it gets assigned one random sprite from the list.


RemoveSprite(Filename)

Removes a specified sprite from the list.

Parameters

Filename
The filename of the sprite to be removed

Return value

Returns true if the method succeeded.


Start(InitialTime)

Executes the particle generation.

Parameters

InitialTime
The period of time to "fast-forward" the particle generation before the particles are first displayed (in milliseconds)

Return value

Returns true if the method succeeded.

Remarks

The InitialTime parameter is used to populate the emitter with particles before it's first displayed on screen. Don't use too long time not to delay the game execution.


Stop()

Shuts down the particle emitter.

Return value

Returns true if the method succeeded.


Pause()

Pauses the particle generation.

Return value

Returns true if the method succeeded.


Resume()

Resumes the particle generation.

Return value

Returns true if the method succeeded.


AddGlobalForce(Name, Angle, Strength)

Adds a global force which will affect all particles equally.

Parameters

Name
The name of the force
Angle
The direction of the force in degrees (0 degrees = up)
Strength
The strength of the force

Return value

Returns true if the method succeeded.


AddPointForce(Name, X, Y, Angle, Strength)

Adds a point force which will affect the particles depending on their distance from the force origin.

Parameters

Name
The name of the force
X
The X position of the force origin
Y
The Y position of the force origin
Angle
The direction of the force in degrees (0 degrees = up)
Strength
The strength of the force

Return value

Returns true if the method succeeded.


RemoveForce(Name)

Removes a force with the given name.

Parameters

Name
The name of the force to be removed

Return value

Returns true if the method succeeded.