Flint Particle System Forum - Color change upon particle death Sun, 11 Dec 2011 00:49:01 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Color change upon particle death http://flintparticles.org/forum/comments.php?DiscussionID=448&Focus=1520#Comment_1520 http://flintparticles.org/forum/comments.php?DiscussionID=448&Focus=1520#Comment_1520 Thu, 20 Jan 2011 15:26:07 +0000 Adz
import org.flintparticles.common.counters.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.common.actions.Age;
import org.flintparticles.common.events.ParticleEvent;
import org.flintparticles.twoD.particles.*;

var emitter:Emitter2D = new Emitter2D();

emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, changeColour );

emitter.counter = new Blast( 500 );

emitter.addInitializer( new ColorInit( 0xFFFF00FF, 0xFF00FFFF ) );
emitter.addInitializer( new Position( new DiscZone( new Point( 200, 200 ), 200 ) ) );
emitter.addInitializer( new Lifetime ( 10,10 ) );

emitter.addAction( new Move() );
emitter.addAction( new Age() );
emitter.addAction( new GravityWell( 25, 200, 200 ) );
emitter.addAction( new GravityWell( 25, 75, 75 ) );
emitter.addAction( new GravityWell( 25, 325, 325 ) );
emitter.addAction( new GravityWell( 25, 75, 325 ) );
emitter.addAction( new GravityWell( 25, 325, 75 ) );

var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 400, 400 ) );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ) );
renderer.addEmitter( emitter );
addChild( renderer );

function changeColour(event:ParticleEvent):void
{

event.particle.color = 0xFF0000CC;
event.particle.revive();
emitter.addExistingParticles( [ event.particle ], true);

}


emitter.start();



I thought that lifetime might be the cause of this problem, so i removed lifetime/age and ran a separate timer that kills the particles every 15 seconds, (which triggers the changeColour function) but they just disappear.

Any help would be great :) Thanks ]]>
Color change upon particle death http://flintparticles.org/forum/comments.php?DiscussionID=448&Focus=1521#Comment_1521 http://flintparticles.org/forum/comments.php?DiscussionID=448&Focus=1521#Comment_1521 Thu, 20 Jan 2011 15:32:12 +0000 Adz
emitter.addExistingParticles( [ event.particle ], true);

to:

emitter.addExistingParticles( [ event.particle ], false);

this results in the particles reviving in the same position, but as they don't have any of the initializers, I think they just just die over and over again instantly. Though I might be able to make that work with some fiddling....hopefully there is an easier way? ]]>
Color change upon particle death http://flintparticles.org/forum/comments.php?DiscussionID=448&Focus=1526#Comment_1526 http://flintparticles.org/forum/comments.php?DiscussionID=448&Focus=1526#Comment_1526 Wed, 26 Jan 2011 04:21:45 +0000 Adz