Packageorg.flixel
Classpublic class FlxEmitter
InheritanceFlxEmitter Inheritance FlxGroup Inheritance FlxBasic Inheritance 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.



Public Properties
 PropertyDefined By
 Inheritedactive : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_ACTIVECOUNT : uint
[static]
FlxBasic
 Inheritedalive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive.
FlxBasic
  bounce : Number
How much each particle should bounce.
FlxEmitter
 Inheritedcameras : Array
An array of camera objects that this object will use during draw().
FlxBasic
 Inheritedexists : 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
 InheritedID : int
IDs seem like they could be pretty useful, huh? They're not actually used for anything yet though.
FlxBasic
 InheritedignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing when the visual debug mode in the debugger overlay is toggled on.
FlxBasic
 Inheritedlength : 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
 InheritedmaxSize : uint
The maximum capacity of this group.
FlxGroup
 Inheritedmembers : 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
 Inheritedvisible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_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
Protected Properties
 PropertyDefined 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
 Inherited_marker : uint
Internal helper variable for recycling objects a la FlxEmitter.
FlxGroup
 Inherited_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
 Inherited_sortIndex : String
Helper for sort.
FlxGroup
 Inherited_sortOrder : int
Helper for sort.
FlxGroup
  _timer : Number
Internal helper for deciding when to launch particles or kill them.
FlxEmitter
Public Methods
 MethodDefined By
  
FlxEmitter(X:Number = 0, Y:Number = 0, Size:Number = 0)
Creates a new FlxEmitter object at a specific position.
FlxEmitter
 Inherited
Adds a new FlxBasic subclass (FlxBasic, FlxSprite, Enemy, etc) to the group.
FlxGroup
  
at(Object:FlxObject):void
Change the emitter's midpoint to match the midpoint of a FlxObject.
FlxEmitter
 Inherited
callAll(FunctionName:String, Recurse:Boolean = true):void
Go through and call the specified function on all members of the group.
FlxGroup
 Inherited
clear():void
Remove all instances of FlxBasic subclass (FlxSprite, FlxBlock, etc) from the list.
FlxGroup
 Inherited
countDead():int
Call this function to find out how many members of the group are dead.
FlxGroup
 Inherited
Call this function to find out how many members of the group are not dead.
FlxGroup
  
destroy():void
[override] Clean up memory.
FlxEmitter
 Inherited
draw():void
[override] Automatically goes through and calls render on everything you added.
FlxGroup
 Inherited
drawDebug(Camera:FlxCamera = null):void
Override this function to draw custom "debug mode" graphics to the specified camera while the debugger's visual mode is toggled on.
FlxBasic
  
This function can be used both internally and externally to emit the next particle.
FlxEmitter
 Inherited
Call this function to retrieve the first object with dead == false in the group.
FlxGroup
 Inherited
getFirstAvailable(ObjectClass:Class = null):FlxBasic
Call this function to retrieve the first object with exists == false in the group.
FlxGroup
 Inherited
Call this function to retrieve the first object with dead == true in the group.
FlxGroup
 Inherited
Call this function to retrieve the first object with exists == true in the group.
FlxGroup
 Inherited
Call this function to retrieve the first index set to 'null'.
FlxGroup
 Inherited
getRandom(StartIndex:uint = 0, Length:uint = 0):FlxBasic
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
 Inherited
postUpdate():void
Post-update is called right after update() on each object in the game loop.
FlxBasic
 Inherited
preUpdate():void
[override] Just making sure we don't increment the active objects count.
FlxGroup
 Inherited
recycle(ObjectClass:Class = null):FlxBasic
Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
FlxGroup
 Inherited
remove(Object:FlxBasic, Splice:Boolean = false):FlxBasic
Removes an object from the group.
FlxGroup
 Inherited
replace(OldObject:FlxBasic, NewObject:FlxBasic):FlxBasic
Replaces an existing FlxBasic with a new one.
FlxGroup
 Inherited
revive():void
Handy function for bringing game objects "back to life".
FlxBasic
 Inherited
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
 Inherited
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
 Inherited
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
Protected Methods
 MethodDefined By
 Inherited
sortHandler(Obj1:FlxBasic, Obj2:FlxBasic):int
Helper function for the sort process.
FlxGroup
Public Constants
 ConstantDefined By
 InheritedASCENDING : int = -1
[static] Use with sort() to sort in ascending order.
FlxGroup
 InheritedDESCENDING : int = 1
[static] Use with sort() to sort in descending order.
FlxGroup
Property Detail
_counterproperty
protected var _counter:uint

Internal counter for figuring out how many particles to launch.

_explodeproperty 
protected var _explode:Boolean

Internal helper for the style of particle emission (all at once, or one at a time).

_pointproperty 
protected var _point:FlxPoint

Internal point object, handy for reusing for memory mgmt purposes.

_quantityproperty 
protected var _quantity:uint

Internal helper for deciding how many particles to launch.

_timerproperty 
protected var _timer:Number

Internal helper for deciding when to launch particles or kill them.

bounceproperty 
public var bounce:Number

How much each particle should bounce. 1 = full bounce, 0 = no bounce.

frequencyproperty 
public var frequency:Number

How often a particle is emitted (if emitter is started with Explode == false).

gravityproperty 
public var gravity:Number

Sets the acceleration.y member of each particle to this value on launch.

heightproperty 
public var height:Number

The height of the emitter. Particles can be randomly generated from anywhere within this box.

lifespanproperty 
public var lifespan:Number

How long each particle lives once it is emitted. Set lifespan to 'zero' for particles to live forever.

maxParticleSpeedproperty 
public var maxParticleSpeed:FlxPoint

The maximum possible velocity of a particle. The default value is (100,100).

maxRotationproperty 
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!

minParticleSpeedproperty 
public var minParticleSpeed:FlxPoint

The minimum possible velocity of a particle. The default value is (-100,-100).

minRotationproperty 
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!

onproperty 
public var on:Boolean

Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this.

particleClassproperty 
public var particleClass:Class

Set your own particle class type here. Default is FlxParticle.

particleDragproperty 
public var particleDrag:FlxPoint

The X and Y drag component of particles launched from the emitter.

widthproperty 
public var width:Number

The width of the emitter. Particles can be randomly generated from anywhere within this box.

xproperty 
public var x:Number

The X position of the top left corner of the emitter in world space.

yproperty 
public var y:Number

The Y position of the top left corner of emitter in world space.

Constructor Detail
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!

Parameters
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.
Method Detail
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.

Returns
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".