The Starling Particle System classes provide an easy way to display particle systems from within the Starling Framework. That way, adding special effects like explosions, smoke, snow, fire, etc. is very easy to do.
The extension consists of three classes:
Particle
: stores the state of a particle, like its position and colorParticleSystem
: the base class for particle systems. Implements a very simple particle movement. To create a custom particle system, extend this class and override the methodscreateParticle
,initParticle
, andadvanceParticle
.ParticleDesignerPS
: a particle system subclass that can display particle systems created with the Particle Designer from 71squared.
In the src
-directory, you will find the three classes described above. You can either copy them directly to your Starling-powered application, or you add the source path to your FlexBuilder project.
The demo
-directory contains a sample project. To compile it, add a reference to the Starling library and add the source directory that contain the particle system classes.
The project contains 4 sample configurations. Switch between configurations in Demo.as
by
changing the code in the constructor:
var psConfig:XML = XML(new FireConfig());
var psTexture:Texture = Texture.fromBitmap(new FireParticle());
The class ParticleSystem
extends DisplayObject
and behaves accordingly. You can add it as a child to the stage or any other container. As usual, you have to add it to a juggler (or call its advanceTime
method once per frame) to animate it.
// create particle system
mParticleSystem = new ParticleDesignerPS(psConfig, psTexture);
mParticleSystem.emitterX = 320;
mParticleSystem.emitterY = 240;
// add it to the stage and the juggler
addChild(mParticleSystem);
Starling.juggler.add(mParticleSystem);
// start emitting particles
mParticleSystem.start();
// stop emitting particles
mParticleSystem.stop();
As soon as the Starling Wiki is online, you will find more information online.