Flint Particle System Forum - "emitterEmpty" not enough, need "emitterDone" event Mon, 12 Dec 2011 00:20:21 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher "emitterEmpty" not enough, need "emitterDone" event http://flintparticles.org/forum/comments.php?DiscussionID=193&Focus=742#Comment_742 http://flintparticles.org/forum/comments.php?DiscussionID=193&Focus=742#Comment_742 Sat, 04 Apr 2009 08:30:27 +0100 turbidity "emitterEmpty" triggers any time an emitter is empty, even if the emitter has a counter that would still produce particles. Useless!

Solution (clumsy hack): I added the "emitterDone" EMITTER_DONE event to the common Emitter class and the EmitterEvent class.
The emitterDone event is triggered when an update happens over 80 times while the emitter is empty.
<code>
// This is a terrible hack in the common Emitter class around line 645:
doneTime++;
dispatchEvent( new EmitterEvent( EmitterEvent.EMITTER_EMPTY ) );
if (doneTime > 80){
dispatchEvent( new EmitterEvent( EmitterEvent.EMITTER_DONE ) );
doneTime = 0;
}
//END
</code>
There is probably a better way of determining when an Emitter is done with it's counter than the above code.


Here is my charge function that creates emitters:
<code>
//
public var renderer:DisplayObjectRenderer=new DisplayObjectRenderer;
addChild(renderer);
//I'm a' chargin my lazor!
public function charge(target:DisplayObject, many:uint = 100, time:Number = 4):void {
var charger:Emitter2D = new Emitter2D;
renderer.addEmitter(charger);
charger.counter = new TimePeriod(many, time, Circular.easeIn);
charger.addInitializer( new ImageClass(Line, 4, 0xFFFFFFFF, "screen") );
charger.addInitializer( new PositionAbsolute(new DiscZone(new Point(target.x, target.y), 50, 20 ) ) );
charger.addInitializer( new Lifetime( 0.5, 1 ) );
charger.addAction( new Age() );
charger.addAction( new Fade() );
charger.addAction( new ColorChange(0xFFDDB6ff, 0xFFFF0000) );
charger.addAction( new Move() );
charger.addAction( new RotateToDirection() );
charger.addAction( new GravityWell( 30, target.x, target.y, 3));
charger.addAction( new DeathZone(new DiscZone(new Point(target.x, target.y), 10 ) ) );
charger.start();
charger.addEventListener("emitterDone", chargeDone);
}

private function chargeDone(e:EmitterEvent):void {
FlashConnect.atrace(e.target);//flash develop trace
e.target.stop();
renderer.removeEmitter(e.target as Emitter);
e.target.removeEventListener("emitterDone", chargeDone);
fireLazor(9000);
}
</code>

Sorry if I've gone about this entirely the wrong way and need to learn more FlintParticle before I post. ]]>
"emitterEmpty" not enough, need "emitterDone" event http://flintparticles.org/forum/comments.php?DiscussionID=193&Focus=747#Comment_747 http://flintparticles.org/forum/comments.php?DiscussionID=193&Focus=747#Comment_747 Mon, 06 Apr 2009 23:11:31 +0100 Richard an earlier post but I haven't implemented it yet - pressure of work more than anything else. I will try to add it to the 2.1 release, which I hope to have ready before too long. ]]>