Starling 粒子particlesystem 使用实例

转自:http://wiki.starling-framework.org/extensions/particlesystem

// 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; on restart, it will continue from the current state
ps.pause();
 
// stop emitting particles; on restart, it will start from scratch
ps.stop();
原文地址:https://www.cnblogs.com/sevenyuan/p/2871616.html