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

Public Properties

Property Type Description
bounce float
frequency float
gravity float
lifespan float
maxParticleSpeed FlxPoint
maxRotation float
minParticleSpeed FlxPoint
minRotation float
on bool
particleClass Object
particleDrag FlxPoint

Protected Properties

Property Type Description
_counter uint
_explode bool
_point FlxPoint
_quantity uint
_timer float

Public Methods

Method Description
FlxEmitter ( float X, float Y, uint size ) : System

Creates a new FlxEmitter object at a specific position. Does NOT automatically generate or attach particles!

at ( FlxObject flxObject ) : void

Change the emitter's midpoint to match the midpoint of a FlxObject.

destroy ( ) : void

Clean up memory.

emitParticle ( ) : void

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

kill ( ) : void

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

makeParticles ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, uint Quantity = 50, uint BakedRotations, bool Multiple = false, float Collide = 0.8f ) : FlxEmitter

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

setRotation ( float Min, float Max ) : void

A more compact way of setting the angular velocity constraints of the emitter.

setSize ( uint Width, uint Height ) : void

A more compact way of setting the width and height of the emitter.

setXSpeed ( float Min, float Max ) : void

A more compact way of setting the X velocity range of the emitter.

setYSpeed ( float Min, float Max ) : void

A more compact way of setting the Y velocity range of the emitter.

start ( bool Explode = true, float Lifespan, float Frequency = 0.1f, uint Quantity ) : void

Call this function to start emitting particles.

update ( ) : void

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

Method Details

FlxEmitter() public method

Creates a new FlxEmitter object at a specific position. Does NOT automatically generate or attach particles!
public FlxEmitter ( float X, float Y, uint size ) : System
X float The X position of the emitter.
Y float The Y position of the emitter.
size uint Optional, specifies a maximum capacity for this emitter.
return System

at() public method

Change the emitter's midpoint to match the midpoint of a FlxObject.
public at ( FlxObject flxObject ) : void
flxObject FlxObject The FlxObject that you want to sync up with.
return void

destroy() public method

Clean up memory.
public destroy ( ) : void
return void

emitParticle() public method

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

kill() public method

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

makeParticles() public method

This function generates a new array of particle sprites to attach to the emitter.
public makeParticles ( Microsoft.Xna.Framework.Graphics.Texture2D graphics, uint Quantity = 50, uint BakedRotations, bool Multiple = false, float Collide = 0.8f ) : FlxEmitter
graphics Microsoft.Xna.Framework.Graphics.Texture2D Texture for the particles - can be one square or a spritesheet. Set Multiple to true if it is a spritesheet and it will automatically create the particles as long as each frame on the spritesheet is square
Quantity uint The number of particles to generate
BakedRotations uint
Multiple bool Whether or not the Texture contains multiple sprites for particles
Collide float The collidability of the particle, 1 = Full and 0 = None
return FlxEmitter

setRotation() public method

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

setSize() public method

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

setXSpeed() public method

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

setYSpeed() public method

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

start() public method

Call this function to start emitting particles.
public start ( bool Explode = true, float Lifespan, float Frequency = 0.1f, uint Quantity ) : void
Explode bool Whether the particles should all burst out at once.
Lifespan float How long each particle lives once emitted. 0 = forever.
Frequency float 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 How many particles to launch. 0 = "all of the particles".
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

Property Details

_counter protected_oe property

Internal counter for figuring out how many particles to launch.
protected uint _counter
return uint

_explode protected_oe property

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

_point protected_oe property

Internal counter for figuring out how many particles to launch.
protected FlxPoint,flxSharp.flxSharp _point
return FlxPoint

_quantity protected_oe property

Internal helper for deciding how many particles to launch.
protected uint _quantity
return uint

_timer protected_oe property

Internal helper for deciding when to launch particles or kill them.
protected float _timer
return float

bounce public_oe property

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

frequency public_oe property

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

gravity public_oe property

Sets the acceleration.y member of each particle to this value on launch.
public float gravity
return float

lifespan public_oe property

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

maxParticleSpeed public_oe property

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

maxRotation public_oe property

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

minParticleSpeed public_oe property

The X position of the top left corner of the emitter in world space. Already inherited by FlxObject. The Y position of the top left corner of emitter in world space. Already inherited by FlxObject. The width of the emitter. Particles can be randomly generated from anywhere within this box. Already inherited by FlxObject. The height of the emitter. Particles can be randomly generated from anywhere within this box. Already inherited by FlxObject. The minimum possible velocity of a particle. The default value is (-100,-100).
public FlxPoint,flxSharp.flxSharp minParticleSpeed
return FlxPoint

minRotation public_oe property

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

on public_oe property

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

particleClass public_oe property

Set your own particle class type here. Default is FlxParticle.
public Object particleClass
return Object

particleDrag public_oe property

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