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 | ||
---|---|---|---|
![]() | acceleration : FlxPoint
How fast the speed of this object is changing.
| FlxObject | |
![]() | active : Boolean
If an object is not alive, the game loop will not automatically call
update() on it. | FlxObject | |
![]() | angle : Number
Set the angle of a sprite to rotate it.
| FlxObject | |
![]() | angularAcceleration : Number
How fast the spin speed should change.
| FlxObject | |
![]() | angularDrag : Number
Like
drag but for spinning. | FlxObject | |
![]() | angularVelocity : Number
This is how fast you want this sprite to spin.
| FlxObject | |
![]() | bottom : Number
The Y coordinate of the bottom of the rectangle.
| FlxRect | |
![]() | colHullX : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | |
![]() | colHullY : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | |
![]() | collideBottom : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | collideLeft : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | collideRight : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | collideTop : Boolean
Flag for direction collision resolution.
| FlxObject | |
![]() | colOffsets : Array
An array of
FlxPoint objects. | FlxObject | |
![]() | colVector : FlxPoint
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | |
![]() | dead : Boolean
Handy for tracking gameplay or animations.
| FlxObject | |
delay : Number
This variable has different effects depending on what kind of emission it is.
| FlxEmitter | ||
![]() | drag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied
when acceleration is not affecting the sprite.
| FlxObject | |
![]() | exists : Boolean
Kind of a global on/off switch for any objects descended from
FlxObject . | FlxObject | |
![]() | fixed : Boolean
Set
fixed to true if you want the object to stay in place during collisions. | FlxObject | |
gravity : Number
Sets the
acceleration.y member of each particle to this value on launch. | FlxEmitter | ||
![]() | _group : Boolean
Dedicated internal flag for whether or not this class is a FlxGroup.
| FlxObject | |
![]() | health : Number
Handy for storing health percentage or armor points or whatever.
| FlxObject | |
![]() | height : Number | FlxRect | |
justEmitted : Boolean
Checks whether you already fired a particle this frame.
| FlxEmitter | ||
![]() | left : Number
The X coordinate of the left side of the rectangle.
| FlxRect | |
![]() | maxAngular : Number
Use in conjunction with
angularAcceleration for fluid spin speed control. | FlxObject | |
maxParticleSpeed : FlxPoint
The maximum possible velocity of a particle.
| FlxEmitter | ||
maxRotation : Number
The maximum possible angular velocity of a particle.
| FlxEmitter | ||
![]() | maxThrust : Number
Used to cap
thrust , helpful and easy!
| FlxObject | |
![]() | maxVelocity : FlxPoint
If you are using
acceleration , you can use maxVelocity with it
to cap the speed automatically (very useful!). | FlxObject | |
![]() | members : Array
Array of all the
FlxObject s 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 | ||
![]() | moves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see
updateMotion() ). | FlxObject | |
on : Boolean
Determines whether the emitter is currently emitting particles.
| FlxEmitter | ||
![]() | onFloor : Boolean
Flag that indicates whether or not you just hit the floor.
| FlxObject | |
![]() | origin : FlxPoint
WARNING: The origin of the sprite will default to its center.
| FlxObject | |
particleDrag : FlxPoint
The X and Y drag component of particles launched from the emitter.
| FlxEmitter | ||
quantity : uint
The number of particles to launch at a time.
| FlxEmitter | ||
![]() | right : Number
The X coordinate of the right side of the rectangle.
| FlxRect | |
![]() | scrollFactor : FlxPoint
A point that can store numbers from 0 to 1 (for X and Y independently)
that governs how much this object is affected by the camera subsystem.
| FlxObject | |
![]() | solid : Boolean
Set
solid to true if you want to collide this object. | FlxObject | |
![]() | thrust : Number
If you want to do Asteroids style stuff, check out thrust,
instead of directly accessing the object's velocity or acceleration.
| FlxObject | |
![]() | top : Number
The Y coordinate of the top of the rectangle.
| FlxRect | |
![]() | velocity : FlxPoint
The basic speed of this object.
| FlxObject | |
![]() | visible : Boolean
If an object is not visible, the game loop will not automatically call
render() on it. | FlxObject | |
![]() | width : Number | FlxRect | |
![]() | x : Number | FlxPoint | |
![]() | y : Number | FlxPoint |
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 | ||
![]() | _first : Boolean | FlxGroup | |
![]() | _fixed : Boolean
Internal tracker for whether an object will move/alter position after a collision (see
fixed ). | FlxObject | |
![]() | _flashPoint : Point
This is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
| FlxObject | |
![]() | _flicker : Boolean
Internal helper used for retro-style flickering.
| FlxObject | |
![]() | _flickerTimer : Number
Internal helper used for retro-style flickering.
| FlxObject | |
![]() | _last : FlxPoint
Helpers for moving/updating group members.
| FlxGroup | |
_particle : uint
Internal marker for where we are in
_sprites . | FlxEmitter | ||
![]() | _point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
| FlxObject | |
![]() | _rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
| FlxObject | |
![]() | _solid : Boolean
Internal tracker for whether or not the object collides (see
solid ). | FlxObject | |
![]() | _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)
Creates a new
FlxEmitter object at a specific position. | FlxEmitter | ||
![]() |
Adds a new
FlxObject subclass (FlxSprite, FlxBlock, etc) to the list of children
| FlxGroup | |
Change the emitter's position to the origin of a
FlxObject . | FlxEmitter | ||
![]() |
If you don't want to call
FlxU.collide() you can use this instead. | FlxObject | |
![]() |
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 | |
![]() |
countOnScreen():int
Returns a count of how many objects in this group are on-screen right now.
| FlxGroup | |
createSprites(Graphics:Class, Quantity:uint = 50, BakedRotations:uint = 16, Multiple:Boolean = true, Collide:Number = 0, Bounce:Number = 0):FlxEmitter
This function generates a new array of sprites to attach to the emitter.
| FlxEmitter | ||
![]() |
destroy():void
Override this function to handle any deleting or "shutdown" type operations you might need,
such as removing traditional Flash children like Sprite objects.
| FlxGroup | |
emitParticle():void
This function can be used both internally and externally to emit the next particle.
| FlxEmitter | ||
![]() |
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
| FlxObject | |
![]() |
flickering():Boolean
Check to see if the object is still flickering.
| FlxObject | |
![]() |
getBoundingColor():uint
Returns the appropriate color for the bounding box depending on object state.
| FlxObject | |
![]() |
Call this function to retrieve the first object with dead == false in the group.
| FlxGroup | |
![]() |
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 | |
![]() |
Call this function to figure out the on-screen position of the object.
| FlxObject | |
![]() |
Called when this object's bottom edge collides with the top of another
FlxObject . | FlxObject | |
![]() |
Called when this object's left side collides with another
FlxObject 's right. | FlxObject | |
![]() |
Called when this object's right side collides with another
FlxObject 's left. | FlxObject | |
![]() |
Since most games have identical behavior for running into walls,
you can just override this function instead of overriding both hitLeft and hitRight.
| FlxObject | |
![]() |
Called when this object's top collides with the bottom of another
FlxObject . | FlxObject | |
![]() |
hurt(Damage:Number):void
Call this function to "damage" (or give health bonus) to this sprite.
| FlxObject | |
kill():void
Call this function to turn off all the particles and the emitter.
| FlxEmitter | ||
![]() |
onScreen():Boolean
Check and see if this object is currently on screen.
| FlxObject | |
![]() |
Checks to see if some
FlxObject object overlaps this FlxObject object. | FlxObject | |
![]() |
overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps this
FlxObject object. | FlxObject | |
![]() |
preCollide(Object:FlxObject):void
FlxU.collide() (and thus FlxObject.collide() ) call
this function each time two objects are compared to see if they collide. | FlxObject | |
![]() |
refreshHulls():void
Called by
FlxObject.updateMotion() and some constructors to
rebuild the basic collision data for this object. | FlxObject | |
![]() |
Removes an object from the group.
| FlxGroup | |
![]() |
render():void
Automatically goes through and calls render on everything you added,
override this loop to control render order manually.
| FlxGroup | |
![]() |
Replaces an existing
FlxObject with a new one. | FlxGroup | |
![]() |
reset(X:Number, Y:Number):void
If the group's position is reset, we want to reset all its members too.
| FlxGroup | |
![]() |
resetFirstAvail(X:Number = 0, Y:Number = 0):Boolean
Finds the first object with exists == false and calls reset on it.
| 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, Delay:Number = 0, Quantity:uint = 0):void
Call this function to start emitting particles.
| FlxEmitter | ||
stop(Delay:Number = 3):void
Call this function to stop the emitter without killing it.
| FlxEmitter | ||
![]() |
toString():String
Convert object to readable string name.
| FlxPoint | |
update():void
Called automatically by the game loop, decides when to launch particles and when to "die".
| FlxEmitter |
Method | Defined by | ||
---|---|---|---|
![]() |
destroyMembers():void
Internal function that actually loops through and destroys each member.
| FlxGroup | |
![]() |
killMembers():void
Internal function that calls kill on all members.
| FlxGroup | |
![]() |
renderMembers():void
Internal function that actually loops through and renders all the group members.
| FlxGroup | |
![]() |
saveOldPosition():void
Internal function, helps with the moving/updating of group members.
| FlxGroup | |
![]() |
Helper function for the sort process.
| FlxGroup | |
updateEmitter():void
Internal function that actually performs the emitter update (called by update()).
| FlxEmitter | ||
![]() |
updateFlickering():void
Just updates the retro-style flickering.
| FlxObject | |
updateMembers():void
Internal function that actually goes through and updates all the group members.
| FlxEmitter | ||
![]() |
updateMotion():void
Internal function for updating the position and speed of this object.
| FlxObject |
_counter | property |
protected var _counter:uint
Internal counter for figuring out how many particles to launch.
delay | property |
public var delay:Number
This variable has different effects depending on what kind of emission it is. During an explosion, delay controls the lifespan of the particles. During normal emission, delay controls the time between particle launches. NOTE: In older builds, polarity (negative numbers) was used to define emitter behavior. THIS IS NO LONGER THE CASE! FlxEmitter.start() controls that now!
_explode | property |
protected var _explode:Boolean
The style of particle emission (all at once, or one at a time).
gravity | property |
public var gravity:Number
Sets the acceleration.y
member of each particle to this value on launch.
justEmitted | property |
public var justEmitted:Boolean
Checks whether you already fired a particle this frame.
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.
_particle | property |
protected var _particle:uint
Internal marker for where we are in _sprites
.
particleDrag | property |
public var particleDrag:FlxPoint
The X and Y drag component of particles launched from the emitter.
quantity | property |
public var quantity:uint
The number of particles to launch at a time.
_timer | property |
protected var _timer:Number
Internal helper for deciding when to launch particles or kill them.
FlxEmitter | () | constructor |
public function FlxEmitter(X:Number = 0, Y: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.
|
at | () | method |
public function at(Object:FlxObject):void
Change the emitter's position to the origin of a FlxObject
.
Object:FlxObject — The FlxObject that needs to spew particles.
|
createSprites | () | method |
public function createSprites(Graphics:Class, Quantity:uint = 50, BakedRotations:uint = 16, Multiple:Boolean = true, Collide:Number = 0, Bounce:Number = 0):FlxEmitter
This function generates a new array of sprites to attach to the emitter.
ParametersGraphics: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 = true ) — 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 ) — 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.
|
|
Bounce:Number (default = 0 ) — Whether the particles should bounce after colliding with things. 0 means no bounce, 1 means full reflection.
|
FlxEmitter —
This FlxEmitter instance (nice for chaining stuff together, if you're into that).
|
emitParticle | () | method |
public function emitParticle():void
This function can be used both internally and externally to emit the next particle.
kill | () | method |
public override function kill():void
Call this function to turn off all the particles and the emitter.
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.
ParametersMin: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.
ParametersWidth: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.
ParametersMin: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.
ParametersMin: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, Delay:Number = 0, Quantity:uint = 0):void
Call this function to start emitting particles.
ParametersExplode:Boolean (default = true ) — Whether the particles should all burst out at once.
|
|
Delay:Number (default = 0 ) — You can set the delay (or lifespan) here if you want.
|
|
Quantity:uint (default = 0 ) — How many particles to launch. Default value is 0, or "all the particles".
|
stop | () | method |
public function stop(Delay:Number = 3):void
Call this function to stop the emitter without killing it.
ParametersDelay:Number (default = 3 ) — How long to wait before killing all the particles. Set to 'zero' to never kill them.
|
update | () | method |
public override function update():void
Called automatically by the game loop, decides when to launch particles and when to "die".
updateEmitter | () | method |
protected function updateEmitter():void
Internal function that actually performs the emitter update (called by update()).
updateMembers | () | method |
protected override function updateMembers():void
Internal function that actually goes through and updates all the group members. Overridden here to remove the position update code normally used by a FlxGroup.