Package | org.flixel |
Class | public class FlxEmitter |
Inheritance | FlxEmitter ![]() ![]() ![]() |
FlxEmitter
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
FlxSprite
objects out at set intervals
by setting their positions and velocities accordingly.
It is easy to use and relatively efficient, since it
automatically redelays its sprites and/or kills
them once they've been launched.
Property | Defined By | ||
---|---|---|---|
![]() | active : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | _ACTIVECOUNT : uint [static] | FlxBasic | |
![]() | alive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive. | FlxBasic | |
bounce : Number | FlxEmitter | ||
![]() | exists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup. | FlxBasic | |
frequency : Number
How often a particle is emitted (if emitter is started with Explode == false). | FlxEmitter | ||
gravity : Number
Sets the acceleration.y member of each particle to this value on launch. | FlxEmitter | ||
height : Number | FlxEmitter | ||
![]() | ID : int
IDs seem like they could be pretty useful, huh?
| FlxBasic | |
![]() | length : Number | FlxGroup | |
lifespan : Number
How long each particle lives once it is emitted. | FlxEmitter | ||
maxParticleSpeed : FlxPoint
The maximum possible velocity of a particle. | FlxEmitter | ||
maxRotation : Number
The maximum possible angular velocity of a particle. | FlxEmitter | ||
![]() | maxSize : uint | FlxGroup | |
![]() | members : Array
Array of all the FlxBasics that exist in this layer. | FlxGroup | |
minParticleSpeed : FlxPoint
The minimum possible velocity of a particle. | FlxEmitter | ||
minRotation : Number
The minimum possible angular velocity of a particle. | FlxEmitter | ||
on : Boolean
Determines whether the emitter is currently emitting particles. | FlxEmitter | ||
particleClass : Class | FlxEmitter | ||
particleDrag : FlxPoint
The X and Y drag component of particles launched from the emitter. | FlxEmitter | ||
![]() | visible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | _VISIBLECOUNT : uint [static] | FlxBasic | |
width : Number | FlxEmitter | ||
x : Number | FlxEmitter | ||
y : Number | FlxEmitter |
Property | Defined By | ||
---|---|---|---|
_counter : uint
Internal counter for figuring out how many particles to launch. | FlxEmitter | ||
_explode : Boolean
The style of particle emission (all at once, or one at a time). | FlxEmitter | ||
![]() | _marker : uint | FlxGroup | |
![]() | _maxSize : uint | FlxGroup | |
_point : FlxPoint | FlxEmitter | ||
_quantity : uint
Internal helper for deciding how many particles to launch. | FlxEmitter | ||
![]() | _sortIndex : String
Helpers for sorting members. | FlxGroup | |
![]() | _sortOrder : int | FlxGroup | |
_timer : Number
Internal helper for deciding when to launch particles or kill them. | FlxEmitter |
Method | Defined By | ||
---|---|---|---|
FlxEmitter(X:Number = 0, Y:Number = 0, Size:Number = 0)
Creates a new FlxEmitter object at a specific position. | FlxEmitter | ||
![]() |
Adds a new FlxBasic subclass (FlxBasic, FlxSprite, MyEnemy, etc) to the group. | FlxGroup | |
Change the emitter's position to the origin of a FlxObject. | FlxEmitter | ||
![]() | clear():void
Remove all instances of FlxBasic subclass (FlxSprite, FlxBlock, etc) from the list. | FlxGroup | |
![]() | countDead():int
Call this function to find out how many members of the group are dead. | FlxGroup | |
![]() | countLiving():int
Call this function to find out how many members of the group are not dead. | FlxGroup | |
destroy():void [override] | FlxEmitter | ||
![]() | draw():void [override]
Automatically goes through and calls render on everything you added,
override this loop to control render order manually. | FlxGroup | |
emitParticle():void
This function can be used both internally and externally to emit the next particle. | FlxEmitter | ||
![]() |
Call this function to retrieve the first object with dead == false in the group. | FlxGroup | |
![]() | getFirstAvail(ObjectClass:Class = null):FlxBasic
Call this function to retrieve the first object with exists == false in the group. | FlxGroup | |
![]() |
Call this function to retrieve the first object with dead == true in the group. | FlxGroup | |
![]() |
Call this function to retrieve the first object with exists == true in the group. | FlxGroup | |
![]() | getFirstNull():int
Call this function to retrieve the first index set to 'null'. | FlxGroup | |
![]() |
Returns a member at random from the group. | FlxGroup | |
kill():void [override]
Call this function to turn off all the particles and the emitter. | FlxEmitter | ||
makeParticles(Graphics:Class, Quantity:uint = 50, BakedRotations:uint = 16, Multiple:Boolean = false, Collide:Number = 0.8):FlxEmitter
This function generates a new array of particle sprites to attach to the emitter. | FlxEmitter | ||
![]() | FlxBasic | ||
![]() | postUpdate():void | FlxBasic | |
![]() | preUpdate():void [override] | FlxGroup | |
![]() |
Recycling is designed to help you reuse game objects without always re-allocating or "newing" them. | FlxGroup | |
![]() |
Removes an object from the group. | FlxGroup | |
![]() |
Replaces an existing FlxBasic with a new one. | FlxGroup | |
![]() | revive():void | FlxBasic | |
![]() | setAll(VariableName:String, Value:Object, Recurse:Boolean = true):void | FlxGroup | |
setRotation(Min:Number = 0, Max:Number = 0):void
A more compact way of setting the angular velocity constraints of the emitter. | FlxEmitter | ||
setSize(Width:uint, Height:uint):void
A more compact way of setting the width and height of the emitter. | FlxEmitter | ||
setXSpeed(Min:Number = 0, Max:Number = 0):void
A more compact way of setting the X velocity range of the emitter. | FlxEmitter | ||
setYSpeed(Min:Number = 0, Max:Number = 0):void
A more compact way of setting the Y velocity range of the emitter. | FlxEmitter | ||
![]() | sort(Index:String = y, Order:int):void
Call this function to sort the group according to a particular value and order. | FlxGroup | |
start(Explode:Boolean = true, Lifespan:Number = 0, Frequency:Number = 0.1, Quantity:uint = 0):void
Call this function to start emitting particles. | FlxEmitter | ||
![]() | toString():String
Convert object to readable string name. | FlxBasic | |
update():void [override]
Called automatically by the game loop, decides when to launch particles and when to "die". | FlxEmitter |
_counter | property |
protected var _counter:uint
Internal counter for figuring out how many particles to launch.
_explode | property |
protected var _explode:Boolean
The style of particle emission (all at once, or one at a time).
_point | property |
protected var _point:FlxPoint
_quantity | property |
protected var _quantity:uint
Internal helper for deciding how many particles to launch.
_timer | property |
protected var _timer:Number
Internal helper for deciding when to launch particles or kill them.
bounce | property |
public var bounce:Number
frequency | property |
public var frequency:Number
How often a particle is emitted (if emitter is started with Explode == false).
gravity | property |
public var gravity:Number
Sets the acceleration.y
member of each particle to this value on launch.
height | property |
public var height:Number
lifespan | property |
public var lifespan:Number
How long each particle lives once it is emitted. Set lifespan to 'zero' for particles to live forever.
maxParticleSpeed | property |
public var maxParticleSpeed:FlxPoint
The maximum possible velocity of a particle. The default value is (100,100).
maxRotation | property |
public var maxRotation:Number
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!
minParticleSpeed | property |
public var minParticleSpeed:FlxPoint
The minimum possible velocity of a particle. The default value is (-100,-100).
minRotation | property |
public var minRotation:Number
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!
on | property |
public var on:Boolean
Determines whether the emitter is currently emitting particles.
particleClass | property |
public var particleClass:Class
particleDrag | property |
public var particleDrag:FlxPoint
The X and Y drag component of particles launched from the emitter.
width | property |
public var width:Number
x | property |
public var x:Number
y | property |
public var y:Number
FlxEmitter | () | Constructor |
public function FlxEmitter(X:Number = 0, Y:Number = 0, Size:Number = 0)
Creates a new FlxEmitter
object at a specific position.
Does not automatically generate or attach particles!
X:Number (default = 0 ) — The X position of the emitter.
| |
Y:Number (default = 0 ) — The Y position of the emitter.
| |
Size:Number (default = 0 )
|
at | () | method |
public function at(Object:FlxObject):void
Change the emitter's position to the origin of a FlxObject
.
Parameters
Object:FlxObject — The FlxObject that needs to spew particles.
|
destroy | () | method |
override public function destroy():void
emitParticle | () | method |
public function emitParticle():void
This function can be used both internally and externally to emit the next particle.
kill | () | method |
override public function kill():void
Call this function to turn off all the particles and the emitter.
makeParticles | () | method |
public function makeParticles(Graphics:Class, Quantity:uint = 50, BakedRotations:uint = 16, Multiple:Boolean = false, Collide:Number = 0.8):FlxEmitter
This function generates a new array of particle sprites to attach to the emitter.
Parameters
Graphics:Class — If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.
| |
Quantity:uint (default = 50 ) — The number of particles to generate when using the "create from image" option.
| |
BakedRotations:uint (default = 16 ) — How many frames of baked rotation to use (boosts performance). Set to zero to not use baked rotations.
| |
Multiple:Boolean (default = false ) — 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:Number (default = 0.8 ) — 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.
|
FlxEmitter — This FlxEmitter instance (nice for chaining stuff together, if you're into that).
|
setRotation | () | method |
public function setRotation(Min:Number = 0, Max:Number = 0):void
A more compact way of setting the angular velocity constraints of the emitter.
Parameters
Min:Number (default = 0 ) — The minimum value for this range.
| |
Max:Number (default = 0 ) — The maximum value for this range.
|
setSize | () | method |
public function setSize(Width:uint, Height:uint):void
A more compact way of setting the width and height of the emitter.
Parameters
Width:uint — The desired width of the emitter (particles are spawned randomly within these dimensions).
| |
Height:uint — The desired height of the emitter.
|
setXSpeed | () | method |
public function setXSpeed(Min:Number = 0, Max:Number = 0):void
A more compact way of setting the X velocity range of the emitter.
Parameters
Min:Number (default = 0 ) — The minimum value for this range.
| |
Max:Number (default = 0 ) — The maximum value for this range.
|
setYSpeed | () | method |
public function setYSpeed(Min:Number = 0, Max:Number = 0):void
A more compact way of setting the Y velocity range of the emitter.
Parameters
Min:Number (default = 0 ) — The minimum value for this range.
| |
Max:Number (default = 0 ) — The maximum value for this range.
|
start | () | method |
public function start(Explode:Boolean = true, Lifespan:Number = 0, Frequency:Number = 0.1, Quantity:uint = 0):void
Call this function to start emitting particles.
Parameters
Explode:Boolean (default = true ) — Whether the particles should all burst out at once.
| |
Lifespan:Number (default = 0 ) — How long each particle lives once emitted. 0 = forever.
| |
Frequency:Number (default = 0.1 ) — 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:uint (default = 0 ) — How many particles to launch. 0 = "all of the particles".
|
update | () | method |
override public function update():void
Called automatically by the game loop, decides when to launch particles and when to "die".