0

I am developing an app in AS3 which utilizes the starling particle extension but I am have some trouble not looping it.

I created a new class in an objects package called particle which has the below code in it.

mParticleSystem = mParticleSystems.shift();
mParticleSystems.push(mParticleSystem);
mParticleSystem.emitterX = 320;
mParticleSystem.emitterY = 240;
mParticleSystem.start();
addChild(mParticleSystem);
Starling.juggler.add(mParticleSystem);

I call this class in my main project by

particle = new Particle();
this.addChild(particle);

Everything works perfectly except I am unable to stop the juggler. I have tried adding an event listener onto the mParticleSystem and call a function to remove but the event doesn't fire. Any guidance is appreciated.

4

1 回答 1

0

我猜你的变量mParticleSystem是类的一个实例starling.extensions.ParticleSystem。在这种情况下,ParticleSystem对象在发射完所有粒子后会调度“完成”事件。您可以使用实际代码查看此快速提示:伟大的 Lee Brimelow 的 Starling Particle Effect Disposal(更新的工作代码位于最开始)。

另一个不错的选择是,您可以ParticleSystem通过将参数传递给其start()方法来指定希望发射粒子的时间:

// emit particles for two seconds, then stop
mParticlesSystem.start(2.0);

因此,您可以ParticleSystem在 2 秒后从杂耍者中移除您的。

希望这可以帮助!

于 2012-11-07T00:13:54.677 回答