Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorhectors
    • CommentTimeOct 6th 2010
     
    Hiya, I've looked through the examples and can't find how to do this. I'm adding a TweenToZone:

    _startEmitter.addAction(new TweenToZone(new BitmapDataZone(__myBitmapData)));

    This works great but I want my particles not to disappear when they reach their destination.

    What's the best way to do this?

    Thanks :)
    • CommentAuthorRichard
    • CommentTimeOct 9th 2010 edited
     
    The tween is tied to the particle's lifetime. As a result, the particle dies when the tween ends.

    However, if you listen for the particle dead event, you can revive the particle and add it to a different emitter which doesn't tween it (or kill it). Something like this

    stableEmitter = new Emitter2D();
    renderer.addEmitter( stableEmitter );
    stableEmitter.start();

    emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, reviveParticle );

    function reviveParticle( event:ParticleEvent ):void
    {
    event.particle.revive();
    stableEmitter.addExistingParticles( [ event.particle ], false );
    }


    You can see a more complete example of this in the Logo Tween example.
  1.  
    Hi Richard,

    i tried this but the particle still has an alpha of 0 so i cant see it. (or something else is wrong).
    Is there a way of getting more control over the lifecycle of the particle? How can i prevent the particle from fading?

    tnx
    • CommentAuthorRichard
    • CommentTimeDec 20th 2010
     
    Set the particle's color when you revive it. The color is a 32bit value, with the first 8 bits (the first FF below) indicating the alpha.

    stableEmitter = new Emitter2D();
    renderer.addEmitter( stableEmitter );
    stableEmitter.start();

    emitter.addEventListener( ParticleEvent.PARTICLE_DEAD, reviveParticle );

    function reviveParticle( event:ParticleEvent ):void
    {
    event.particle.revive();
    event.particle.color = 0xFFFFFFFF;
    stableEmitter.addExistingParticles( [ event.particle ], false );
    }