Flint Particle System Forum - Revive a particle where it died 2012-05-26T06:19:25+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Revive a particle where it died http://flintparticles.org/forum/comments.php?DiscussionID=549&Focus=1877#Comment_1877 2012-01-15T05:50:53+00:00 2012-05-26T06:19:25+01:00 fred http://flintparticles.org/forum/account.php?u=510 Hello, I am trying to revive the same particle at the same position where it died using TwoWay.sine for the age... so far, the particle gets a new random x and y. Thanks for your ... fred

var myApple:Apple = new Apple();
var myMickey:Mickey = new Mickey();
var myMarlboro:Marlboro = new Marlboro();
var myNike:Nike = new Nike();

var myArray:Array = [myApple, myMickey, myMarlboro, myNike ];

renderer = new DisplayObjectRenderer();
addChild(renderer);
emitter = new Emitter2D();
renderer.addEmitter(emitter);

emitter.addInitializer( new Position( new RectangleZone( 0, 0, 1024, 768)));
emitter.addInitializer( new Lifetime(10, 20));
emitter.addAction( new Move());
emitter.addAction( new Age(TwoWay.sine));
emitter.addAction( new Fade());

var myParticles:Vector.<Particle> = Particle2DUtils.createParticles2DFromDisplayObjects( myArray );
emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, revive4Particles );

emitter.addParticles( myParticles , true);
emitter.start();

private function revive4Particles( event:ParticleEvent ):void
{
event.particle.revive();
event.currentTarget.addParticle(Particle2D(event.particle), true);
}]]>
Revive a particle where it died http://flintparticles.org/forum/comments.php?DiscussionID=549&Focus=1878#Comment_1878 2012-01-21T11:13:16+00:00 2012-05-26T06:19:25+01:00 Richard http://flintparticles.org/forum/account.php?u=1 The second parameter in the addParticle method indicates whether the emitter's initializers should be applied to the particle being added. By setting it to true you are applying the emitter's ... Revive a particle where it died http://flintparticles.org/forum/comments.php?DiscussionID=549&Focus=1879#Comment_1879 2012-01-22T01:55:39+00:00 2012-05-26T06:19:25+01:00 fred http://flintparticles.org/forum/account.php?u=510 Hey Richard, Thanks for your response. I understand that if set to true, I am applying the emitter's initializers to the particle. I could set it to false but I need other addInitializers like ... Thanks for your response. I understand that if set to true, I am applying the emitter's initializers to the particle.
I could set it to false but I need other addInitializers like Lifetime and also actions like Move, Age and Fade.
Any way to select what to apply?
Should I recreate a new emitter, pass the particule and kill the old one?
Thx again.
Fred]]>
Revive a particle where it died http://flintparticles.org/forum/comments.php?DiscussionID=549&Focus=1880#Comment_1880 2012-01-22T02:15:05+00:00 2012-05-26T06:19:25+01:00 fred http://flintparticles.org/forum/account.php?u=510 SOLVED :) Removing the position Initializer did the trick. thx var myApple:Apple = new Apple(); var myMickey:Mickey = new Mickey(); var myMarlboro:Marlboro = new Marlboro(); var myNike:Nike = ... Removing the position Initializer did the trick.
thx

var myApple:Apple = new Apple();
var myMickey:Mickey = new Mickey();
var myMarlboro:Marlboro = new Marlboro();
var myNike:Nike = new Nike();

var myPosition:Position;

var myArray:Array = [myApple, myMickey, myMarlboro, myNike ];

renderer = new DisplayObjectRenderer();
addChild(renderer);
emitter = new Emitter2D();
renderer.addEmitter(emitter);

myPosition = new Position(new RectangleZone( 0, 0, 1024, 768));
emitter.addInitializer( myPosition );

emitter.addInitializer( new Lifetime(10, 20));
emitter.addAction( new Move());
emitter.addAction( new Age(TwoWay.sine));
emitter.addAction( new Fade());

var myParticles:Vector.<Particle> = Particle2DUtils.createParticles2DFromDisplayObjects( myArray );
emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, revive4Particles );

emitter.addParticles( myParticles , true);
emitter.start();

private function revive4Particles( event:ParticleEvent ):void
{
event.particle.revive();

emitter.removeInitializer( myPosition );

event.currentTarget.addParticle(Particle2D(event.particle), true);
}]]>