智慧 + 毅力 = 无所不能

正确性、健壮性、可靠性、效率、易用性、可读性、可复用性、兼容性、可移植性...

导航

Starling 粒子particlesystem 使用实例

Posted on 2013-01-22 16:29  Bill Yuan  阅读(1531)  评论(0编辑  收藏  举报

转自: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();