Package | org.flixel |
Class | public class FlxEmitter |
Inheritance | FlxEmitter FlxGroup FlxBasic Object |
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
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.
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
How much each particle should bounce. | FlxEmitter | ||
cameras : Array
An array of camera objects that this object will use during draw(). | FlxBasic | ||
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
The height of the emitter. | FlxEmitter | ||
ID : int
IDs seem like they could be pretty useful, huh?
They're not actually used for anything yet though. | FlxBasic | ||
ignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing
when the visual debug mode in the debugger overlay is toggled on. | FlxBasic | ||
length : Number
The number of entries in the members array. | 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
The maximum capacity of this group. | FlxGroup | ||
members : Array
Array of all the FlxBasics that exist in this group. | 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
Set your own particle class type here. | 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
The width of the emitter. | FlxEmitter | ||
x : Number
The X position of the top left corner of the emitter in world space. | FlxEmitter | ||
y : Number
The Y position of the top left corner of emitter in world space. | FlxEmitter |
Property | Defined By | ||
---|---|---|---|
_counter : uint
Internal counter for figuring out how many particles to launch. | FlxEmitter | ||
_explode : Boolean
Internal helper for the style of particle emission (all at once, or one at a time). | FlxEmitter | ||
_marker : uint
Internal helper variable for recycling objects a la FlxEmitter. | FlxGroup | ||
_maxSize : uint
Internal tracker for the maximum capacity of the group. | FlxGroup | ||
_point : FlxPoint
Internal point object, handy for reusing for memory mgmt purposes. | FlxEmitter | ||
_quantity : uint
Internal helper for deciding how many particles to launch. | FlxEmitter | ||
_sortIndex : String
Helper for sort. | FlxGroup | ||
_sortOrder : int
Helper for sort. | 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, Enemy, etc) to the group. | FlxGroup | ||
Change the emitter's midpoint to match the midpoint of a FlxObject. | FlxEmitter | ||
callAll(FunctionName:String, Recurse:Boolean = true):void
Go through and call the specified function on all members of the group. | FlxGroup | ||
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]
Clean up memory. | FlxEmitter | ||
draw():void [override]
Automatically goes through and calls render on everything you added. | FlxGroup | ||
Override this function to draw custom "debug mode" graphics to the
specified camera while the debugger's visual mode is toggled on. | FlxBasic | ||
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 | ||
getFirstAvailable(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 | ||
postUpdate():void
Post-update is called right after update() on each object in the game loop. | FlxBasic | ||
preUpdate():void [override]
Just making sure we don't increment the active objects count. | 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
Handy function for bringing game objects "back to life". | FlxBasic | ||
setAll(VariableName:String, Value:Object, Recurse:Boolean = true):void
Go through and set the specified variable to the specified value on all members of the group. | 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
Internal helper for the style of particle emission (all at once, or one at a time).
_point | property |
protected var _point:FlxPoint
Internal point object, handy for reusing for memory mgmt purposes.
_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
How much each particle should bounce. 1 = full bounce, 0 = no bounce.
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
The height of the emitter. Particles can be randomly generated from anywhere within this box.
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. It is totally safe to directly toggle this.
particleClass | property |
public var particleClass:Class
Set your own particle class type here.
Default is FlxParticle
.
particleDrag | property |
public var particleDrag:FlxPoint
The X and Y drag component of particles launched from the emitter.
width | property |
public var width:Number
The width of the emitter. Particles can be randomly generated from anywhere within this box.
x | property |
public var x:Number
The X position of the top left corner of the emitter in world space.
y | property |
public var y:Number
The Y position of the top left corner of emitter in world space.
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 ) — Optional, specifies a maximum capacity for this emitter.
|
at | () | method |
public function at(Object:FlxObject):void
Change the emitter's midpoint to match the midpoint of a FlxObject
.
Parameters
Object:FlxObject — The FlxObject that you want to sync up with.
|
destroy | () | method |
override public function destroy():void
Clean up memory.
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".