class FlxTypedEmitter<T>
package flixel.effects.particles
extends FlxTypedGroup › FlxBasic
import flixel.effects.particles.FlxEmitter
FlxTypedEmitter is a lightweight particle emitter.
It can be used for one-time explosions or for continuous fx like rain and fire.
FlxEmitter
is not optimized or anything; all it does is launch FlxParticle
objects out
at set intervals by setting their positions and velocities accordingly.
It is easy to use and relatively efficient, relying on FlxGroup
's RECYCLE POWERS.
Constructor
new(X:Float = 0, Y:Float = 0, Size:Int = 0)
Creates a new FlxTypedEmitter
object at a specific position.
Does NOT automatically generate or attach particles!
Parameters:
X | The X position of the emitter. |
---|---|
Y | The Y position of the emitter. |
Size | Optional, specifies a maximum capacity for this emitter. |
Variables
read onlyacceleration:FlxPointRangeBounds = new FlxPointRangeBounds(0, 0)
Sets the acceleration
range of particles launched from this emitter.
Set acceleration y-values to give particles gravity.
allowCollisions:FlxDirectionFlags = NONE
Sets the allowCollisions
value for particles launched from this emitter.
Set to NONE
by default. Don't forget to call FlxG.collide()
in your update loop!
read onlyalpha:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(1)
Sets alpha
range of particles launched from this emitter.
read onlyangle:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(0)
The angle range of particles launched from this emitter.
angle.end
is ignored unless ignoreAngularVelocity
is set to true
.
read onlyangularAcceleration:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(0, 0)
Set the angular acceleration range of particles launched from this emitter.
read onlyangularDrag:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(0, 0)
Set the angular drag range of particles launched from this emitter.
read onlyangularVelocity:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(0, 0)
The angular velocity range of particles launched from this emitter.
autoUpdateHitbox:Bool = false
Sets the autoUpdateHitbox
flag for particles launched from this emitter.
If true, the particles' hitbox will be updated to match scale.
read onlycolor:FlxRangeBounds<FlxColor> = new FlxRangeBounds(FlxColor.WHITE, FlxColor.WHITE)
Sets color
range of particles launched from this emitter.
read onlydrag:FlxPointRangeBounds = new FlxPointRangeBounds(0, 0)
Sets X and Y drag component of particles launched from this emitter.
read onlyelasticity:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(0)
Sets the elasticity
, or bounce, range of particles launched from this emitter.
emitting:Bool = false
Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this.
height:Float = 0
The height of this emitter. Particles can be randomly generated from anywhere within this box.
ignoreAngularVelocity:Bool = false
Set this if you want to specify the beginning and ending value of angle,
instead of using angularVelocity
(or angularAcceleration
).
read onlylaunchAngle:FlxBounds<Float> = new FlxBounds<Float>(-180, 180)
The angle range at which particles will be launched from this emitter.
Ignored unless launchMode
is set to FlxEmitterMode.CIRCLE
.
launchMode:FlxEmitterMode = FlxEmitterMode.CIRCLE
How particles should be launched. If CIRCLE
, particles will use launchAngle
and speed
.
Otherwise, particles will just use velocity.x
and velocity.y
.
read onlylifespan:FlxBounds<Float> = new FlxBounds<Float>(3)
The life, or duration, range of particles launched from this emitter.
particleClass:Class<T> = cast FlxParticle
Set your own particle class type here. The custom class must extend FlxParticle
. Default is FlxParticle
.
read onlyscale:FlxPointRangeBounds = new FlxPointRangeBounds(1, 1)
Sets scale
range of particles launched from this emitter.
solid:Bool
Shorthand for toggling allowCollisions
between ANY
(if true
) and NONE
(if false
).
Don't forget to call FlxG.collide()
in your update loop!
read onlyspeed:FlxRangeBounds<Float> = new FlxRangeBounds<Float>(0, 100)
Set the speed range of particles launched from this emitter. Only used with FlxEmitterMode.CIRCLE
.
read onlyvelocity:FlxPointRangeBounds = new FlxPointRangeBounds(-100, -100, 100, 100)
Sets the velocity range of particles launched from this emitter. Only used with FlxEmitterMode.SQUARE
.
Methods
loadParticles(Graphics:FlxGraphicAsset, Quantity:Int = 50, bakedRotationAngles:Int = 16, Multiple:Bool = false, AutoBuffer:Bool = false):FlxTypedEmitter<T>
This function generates a new array of particle sprites to attach to the emitter.
Parameters:
Graphics | If you opted to not pre-configure an array of |
---|---|
Quantity | The number of particles to generate when using the "create from image" option. |
BakedRotations | How many frames of baked rotation to use (boosts performance). Set to zero to not use baked rotations. |
Multiple | Whether the image in the |
AutoBuffer | Whether to automatically increase the image size to accommodate rotated corners.
Default is |
Returns:
This FlxEmitter
instance (nice for chaining stuff together).
makeParticles(Width:Int = 2, Height:Int = 2, Color:FlxColor = FlxColor.WHITE, Quantity:Int = 50):FlxTypedEmitter<T>
Similar to FlxSprite#makeGraphic()
, this function allows you to quickly make single-color particles.
Parameters:
Width | The width of the generated particles. Default is |
---|---|
Height | The height of the generated particles. Default is |
Color | The color of the generated particles. Default is white. |
Quantity | How many particles to generate. Default is |
Returns:
This FlxEmitter
instance (nice for chaining stuff together).
inlinesetPosition(X:Float = 0, Y:Float = 0):Void
Helper function to set the coordinates of this object.
start(Explode:Bool = true, Frequency:Float = 0.1, Quantity:Int = 0):FlxTypedEmitter<T>
Call this function to start emitting particles.
Parameters:
Explode | Whether the particles should all burst out at once. |
---|---|
Frequency | Ignored if |
Quantity | How many particles to launch. |
Returns:
This FlxEmitter
instance (nice for chaining stuff together).