class flixel.effects.particles.FlxTypedEmitter<T> extends FlxTypedGroup<FlxSprite>
Available on all platforms
Sub classes | ||||||
![]() | FlxEmitter, FlxTypedEmitterExt |
|
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.
Instance Fields
How long each particle lives once it is emitted. * Set lifespan to 'zero' for particles to live forever.
var maxRotation:Float
The maximum possible angular velocity of a particle. The default value is 360. * NOTE: rotating particles are more expensive to draw than non-rotating ones!
var minRotation:Float
The minimum possible angular velocity of a particle. The default value is -360. * NOTE: rotating particles are more expensive to draw than non-rotating ones!
Determines whether the emitter is currently emitting particles. * It is totally safe to directly toggle this.
var particleClass:Class<T>
Set your own particle class type here. The custom class must extend FlxParticle. * Default is FlxParticle.
The minimum and maximum possible angular velocity of a particle. The default value is (-360, 360). * NOTE: rotating particles are more expensive to draw than non-rotating ones!
function new(?X:Float = 0, ?Y:Float = 0, ?Size:Int = 0):Void
Creates a new FlxTypedEmitter object at a specific position. * Does NOT automatically generate or attach particles! * *
X | The X position of the emitter. * |
Y | The Y position of the emitter. * |
Size | Optional, specifies a maximum capacity for this emitter. |
function at(Object:FlxObject):Void
Change the emitter's midpoint to match the midpoint of a FlxObject. * *
Object | The FlxObject that you want to sync up with. |
function emitParticle():Void
This function can be used both internally and externally to emit the next particle.
function makeParticles(Graphics:Dynamic, ?Quantity:Int = 50, ?bakedRotationAngles:Int = 16, ?Multiple:Bool = false, ?Collide:Float = 0.8f, ?AutoBuffer:Bool = false):FlxTypedEmitter<T>
This function generates a new array of particle sprites to attach to the emitter. * *
Graphics | If you opted to not pre-configure an array of FlxParticle objects, you can simply pass in a particle image or sprite sheet. * |
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 Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!). * |
Collide | Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box. * |
AutoBuffer | Whether to automatically increase the image size to accomodate rotated corners. Default is false. Will create frames that are 150% larger on each axis than the original frame or graphic. * |
returns | This FlxEmitter instance (nice for chaining stuff together, if you're into that). |
function setAlpha(?StartMin:Float = 1, ?StartMax:Float = 1, ?EndMin:Float = 1, ?EndMax:Float = 1):Void
A more compact way of setting the alpha constraints of the emitter. * *
StartMin | The minimum value for particle alpha at the start (emission). * |
StartMax | The maximum value for particle alpha at the start (emission). * |
EndMin | The minimum value for particle alpha at the end (death). * |
EndMax | The maximum value for particle alpha at the end (death). |
function setColor(?Start:Int = 16777215, ?End:Int = 16777215):Void
A more compact way of setting the color constraints of the emitter. * But it's not so flexible as setting values of each color bounds objects. * *
Start | The start particles color at the start (emission). * |
EndMin | The end particles color at the end (death). |
function setPosition(?X:Float = 0, ?Y:Float = 0):Void
Helper function to set the coordinates of this object. * Handy since it only requires one line of code. * *
X | The new x position * |
Y | The new y position |
function setRotation(?Min:Float = 0, ?Max:Float = 0):Void
A more compact way of setting the angular velocity constraints of the emitter. * *
Min | The minimum value for this range. * |
Max | The maximum value for this range. |
function setScale(?StartMin:Float = 1, ?StartMax:Float = 1, ?EndMin:Float = 1, ?EndMax:Float = 1):Void
A more compact way of setting the scale constraints of the emitter. * *
StartMin | The minimum value for particle scale at the start (emission). * |
StartMax | The maximum value for particle scale at the start (emission). * |
EndMin | The minimum value for particle scale at the end (death). * |
EndMax | The maximum value for particle scale at the end (death). |
function setSize(Width:Int, Height:Int):Void
A more compact way of setting the width and height of the emitter. * *
Width | The desired width of the emitter (particles are spawned randomly within these dimensions). * |
Height | The desired height of the emitter. |
function setXSpeed(?Min:Float = 0, ?Max:Float = 0):Void
A more compact way of setting the X velocity range of the emitter. * *
Min | The minimum value for this range. * |
Max | The maximum value for this range. |
function setYSpeed(?Min:Float = 0, ?Max:Float = 0):Void
A more compact way of setting the Y velocity range of the emitter. * *
Min | The minimum value for this range. * |
Max | The maximum value for this range. |
function start(?Explode:Bool = true, ?Lifespan:Float = 0, ?Frequency:Float = 0.1f, ?Quantity:Int = 0, ?LifespanRange:Float = 0):Void
Call this function to start emitting particles. *
Explode | Whether the particles should all burst out at once. * |
Lifespan | How long each particle lives once emitted. 0 = forever. * |
Frequency | Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds. * |
Quantity | How many particles to launch. 0 = "all of the particles". * |
LifespanRange | Max amount to add to the particle's lifespan. Leave it to default (zero), if you want to make particle "live" forever (plus you should set Lifespan parameter to zero too). |