C# Class XnaFlixel.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.
Inheritance: FlxGroup
Mostra file Open project: jsbeckr/XnaFlixel

Public Properties

Property Type Description
delay float
justEmitted bool
maxParticleSpeed Vector2
minParticleSpeed Vector2
particleDrag Vector2

Public Methods

Method Description
At ( FlxObject Object ) : void

Change the emitter's position to the origin of a FlxObject. @param Object The FlxObject that needs to spew particles.

CreateSprites ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, int quantity ) : FlxEmitter

This function generates a new array of sprites to attach to the emitter.

CreateSprites ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, int quantity, bool Multiple ) : FlxEmitter

This function generates a new array of sprites to attach to the emitter.

CreateSprites ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, int quantity, bool Multiple, float Collide, float Bounce ) : FlxEmitter

This function generates a new array of sprites to attach to the emitter.

EmitParticle ( ) : void

This function can be used both internally and externally to emit the next particle.

FlxEmitter ( ) : System.Collections.Generic

Creates a new FlxEmitter object at a specific position. Does not automatically generate or attach particles! @param X The X position of the emitter. @param Y The Y position of the emitter.

FlxEmitter ( int x, int y ) : System.Collections.Generic
Kill ( ) : void

Call this function to turn off all the particles and the emitter.

SetRotation ( ) : void

A more compact way of setting the angular velocity constraints of the emitter. @param Min The minimum value for this range. @param Max The maximum value for this range.

SetRotation ( float Min, float Max ) : void
SetSize ( int Width, int Height ) : void

A more compact way of setting the width and height of the emitter. @param Width The desired width of the emitter (particles are spawned randomly within these dimensions). @param Height The desired height of the emitter.

SetXSpeed ( ) : void

A more compact way of setting the X velocity range of the emitter. @param Min The minimum value for this range. @param Max The maximum value for this range.

SetXSpeed ( float Min, float Max ) : void
SetYSpeed ( ) : void

A more compact way of setting the Y velocity range of the emitter. @param Min The minimum value for this range. @param Max The maximum value for this range.

SetYSpeed ( float Min, float Max ) : void
Start ( ) : void

Call this function to start emitting particles. @param Explode Whether the particles should all burst out at once. @param Delay You can set the delay (or lifespan) here if you want. @param quantity How many particles to launch. Default value is 0, or "all the particles".

Start ( bool Explode, float Delay ) : void
Start ( bool Explode, float Delay, int Quantity ) : void
Stop ( ) : void

Call this function to stop the emitter without killing it. @param Delay How long to wait before killing all the particles. Set to 'zero' to never kill them.

Stop ( float Delay ) : void
Update ( ) : void

Called automatically by the game loop, decides when to launch particles and when to "die".

Protected Methods

Method Description
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.

Private Methods

Method Description
Initialize ( int x, int y ) : void
UpdateEmitter ( ) : void

Internal function that actually performs the emitter update (called by update()).

Method Details

At() public method

Change the emitter's position to the origin of a FlxObject. @param Object The FlxObject that needs to spew particles.
public At ( FlxObject Object ) : void
Object FlxObject
return void

CreateSprites() public method

This function generates a new array of sprites to attach to the emitter.
public CreateSprites ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, int quantity ) : FlxEmitter
graphics Microsoft.Xna.Framework.Graphics.Texture2D If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.
quantity int The number of particles to generate when using the "create from image" option.
return FlxEmitter

CreateSprites() public method

This function generates a new array of sprites to attach to the emitter.
public CreateSprites ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, int quantity, bool Multiple ) : FlxEmitter
graphics Microsoft.Xna.Framework.Graphics.Texture2D If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.
quantity int The number of particles to generate when using the "create from image" option.
Multiple bool 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!).
return FlxEmitter

CreateSprites() public method

This function generates a new array of sprites to attach to the emitter.
public CreateSprites ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, int quantity, bool Multiple, float Collide, float Bounce ) : FlxEmitter
graphics Microsoft.Xna.Framework.Graphics.Texture2D If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.
quantity int The number of particles to generate when using the "create from image" option.
Multiple bool 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 float 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 float Whether the particles should bounce after colliding with things. 0 means no bounce, 1 means full reflection.
return FlxEmitter

EmitParticle() public method

This function can be used both internally and externally to emit the next particle.
public EmitParticle ( ) : void
return void

FlxEmitter() public method

Creates a new FlxEmitter object at a specific position. Does not automatically generate or attach particles! @param X The X position of the emitter. @param Y The Y position of the emitter.
public FlxEmitter ( ) : System.Collections.Generic
return System.Collections.Generic

FlxEmitter() public method

public FlxEmitter ( int x, int y ) : System.Collections.Generic
x int
y int
return System.Collections.Generic

Kill() public method

Call this function to turn off all the particles and the emitter.
public Kill ( ) : void
return void

SetRotation() public method

A more compact way of setting the angular velocity constraints of the emitter. @param Min The minimum value for this range. @param Max The maximum value for this range.
public SetRotation ( ) : void
return void

SetRotation() public method

public SetRotation ( float Min, float Max ) : void
Min float
Max float
return void

SetSize() public method

A more compact way of setting the width and height of the emitter. @param Width The desired width of the emitter (particles are spawned randomly within these dimensions). @param Height The desired height of the emitter.
public SetSize ( int Width, int Height ) : void
Width int
Height int
return void

SetXSpeed() public method

A more compact way of setting the X velocity range of the emitter. @param Min The minimum value for this range. @param Max The maximum value for this range.
public SetXSpeed ( ) : void
return void

SetXSpeed() public method

public SetXSpeed ( float Min, float Max ) : void
Min float
Max float
return void

SetYSpeed() public method

A more compact way of setting the Y velocity range of the emitter. @param Min The minimum value for this range. @param Max The maximum value for this range.
public SetYSpeed ( ) : void
return void

SetYSpeed() public method

public SetYSpeed ( float Min, float Max ) : void
Min float
Max float
return void

Start() public method

Call this function to start emitting particles. @param Explode Whether the particles should all burst out at once. @param Delay You can set the delay (or lifespan) here if you want. @param quantity How many particles to launch. Default value is 0, or "all the particles".
public Start ( ) : void
return void

Start() public method

public Start ( bool Explode, float Delay ) : void
Explode bool
Delay float
return void

Start() public method

public Start ( bool Explode, float Delay, int Quantity ) : void
Explode bool
Delay float
Quantity int
return void

Stop() public method

Call this function to stop the emitter without killing it. @param Delay How long to wait before killing all the particles. Set to 'zero' to never kill them.
public Stop ( ) : void
return void

Stop() public method

public Stop ( float Delay ) : void
Delay float
return void

Update() public method

Called automatically by the game loop, decides when to launch particles and when to "die".
public Update ( ) : void
return void

UpdateMembers() protected method

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.
protected UpdateMembers ( ) : void
return void

Property Details

delay public_oe property

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!
public float delay
return float

justEmitted public_oe property

Checks whether you already fired a particle this frame.
public bool justEmitted
return bool

maxParticleSpeed public_oe property

The maximum possible velocity of a particle. The default value is (100,100).
public Vector2 maxParticleSpeed
return Vector2

minParticleSpeed public_oe property

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

particleDrag public_oe property

The X and Y drag component of particles launched from the emitter.
public Vector2 particleDrag
return Vector2