This class provides an easy way to display particle systems.
Particle Systems can be used to create special effects like explosions, smoke, snow, fire, etc. To provide that flexibility, it can be configured with numerous settings that control particle movement, size, color, etc.
Finding the perfect settings for your effect is not easy. For that reason, there are tools that allow you to modify the settings and preview the resulting particle system in real time.
demo-directory contains a sample project with four sample configurations. Switch between configurations in
Demo.as by hitting the space key.
The following sample configurations are provided:
The extension contains two Particle System classes:
// embed configuration XML [Embed(source="fire.pex", mimeType="application/octet-stream")] private static const FireConfig:Class; // embed particle texture [Embed(source = "fire_particle.png")] private static const FireParticle:Class; // instantiate embedded objects var psConfig:XML = XML(new FireConfig()); var psTexture:Texture = Texture.fromBitmap(new FireParticle()); // create particle system var ps:PDParticleSystem = new PDParticleSystem(psConfig, psTexture); ps.x = 160; ps.y = 240; // add it to the stage and the juggler addChild(ps); Starling.juggler.add(ps); // change position where particles are emitted ps.emitterX = 20; ps.emitterY = 40; // start emitting particles ps.start(); // emit particles for two seconds, then stop ps.start(2.0); // stop emitting particles; the existing particles will continue to animate. ps.stop(); // stop emitting particles; the existing particles will be removed. ps.stop(true);
The particle system's bounds are always a zero-sized rectangle, because calculating the real bounds would be very time-consuming. That means that you can't touch a particle system.
The emitter location you can set in the Particle Designer is ignored, too. To move the particle system around, change the
y-properties of the particle system, or the
emitterY-properties at run-time. (While the former moves the complete coordinate system around, the latter just changes where new particles appear.)
Furthermore, the movement of particles is upside-down in Starling, compared to the Particle Designer. That's because Starling uses another coordinate system (with the origin at the top left). To work around that, you can either set the “scaleY” property of the particle system to “-1”, or design the particle system upside down.
The Starling user Michael Trenkler created an advanced version of this particle system class, which adds tons of additional features. So if you're looking for more control over you particle systems, definitely have a look at his Improved Particle System!
You can browse the source code of the particle system on its GitHub page.
Feel free to edit this part of the page!
Where oh where has the “pause” method gone? People need the ability to pause their games. bring it back please….