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

  1.  
    I have a single particle travelling across the screen. It dies within 1 second.
    My emitter listens for the ParticleEvent.PARTICLE_DEAD event.
    From what I've gathered, the event is dispatched and first AFTER the event has been handled, the particle is removed.

    However, in my event handler for the event, I try this:
    trace(e.particle.image.x);
    trace(e.particle.image.y);

    Both return 0.

    trace(e.particle.isDead);
    returns true as well

    So the particle is removed before the event is handled, or at least before the code in the event handler runs.

    How would one go about to try and figure out the x/y after a particle dies?
    • CommentAuthorRichard
    • CommentTimeAug 8th 2009
     
    When a particle dies, the emitter dispatches a particleDead event which caries information about the particle, including its location.
    • CommentAuthorgordeaoux
    • CommentTimeNov 2nd 2009
     
    I'm having the same problem as TackleMcClean, I get 0 in the output:
    emitter.addEventListener(ParticleEvent.PARTICLE_DEAD, pDead);
    function pDead(ef:ParticleEvent):void{
    trace(ef.target.x)
    }

    I assume it's because the "target" refers to the Emitter2d object and not the particle. How do I figure out which particle has just died, or it's properties? Is particleDead different than ParticleEvent.PARTICLE_DEAD?
    • CommentAuthorgordeaoux
    • CommentTimeNov 2nd 2009
     
    Never mind, fixed it. I thought I had tried this before, but it works now:

    function pDead(ef:ParticleEvent):void{
    trace(ef.particle.image.x)
    }

    emitter.addEventListener(ParticleEvent.PARTICLE_DEAD, pDead);
    • CommentAuthorRichard
    • CommentTimeNov 2nd 2009 edited
     
    This should also work

    function pDead(ef:ParticleEvent):void{
    trace(ef.particle.x)
    }