Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my game I use particle effect for various purposes. In that I detect the completion of the particle effect. Basically I want to do something after completion of the particle effect. But the problem is that I didn't able to find the particle effect completion. So any community member please help me.

EDIT : I was creating particle effect using following code

    pointParticleEmtitter = new PointParticleEmitter(pX, pY);

    particleSystem = new ParticleSystem(pointParticleEmtitter, maxRate,
            minRate, maxParticles, mParticleTextureRegion.deepCopy());

    particleSystem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    particleSystem.addParticleInitializer(new ColorInitializer(0f, 0f, 1f));
    particleSystem.addParticleModifier(new AlphaModifier(1, 0, 0, 0.5f));
    particleSystem.addParticleModifier(new ExpireModifier(0.5f));
    gameObject.getScene().attachChild(particleSystem);

Using above code the particle effect was started but when finished that I want to detect. After finishing effect I want to remove the object from the scene.

share|improve this question
    
This question is way too vague, we don't have crystal balls here. What technology are you using? Can you show relevant code? What would you like to do after the particle effect is finished (return to the pool, destroy, start a new effect)? How are you currently trying to detect if a particle effect is finished? –  Roy T. Jun 8 '12 at 10:57
    
Thanks for you response, I modified my question as per you say. –  Siddharth Jun 8 '12 at 11:03
    
What framework are you using? Some sort of Java + OpenGL thingey? –  Roy T. Jun 8 '12 at 11:52
1  
I was using andengine GLES1 that thing was mentioned after the question. –  Siddharth Jun 8 '12 at 12:16

1 Answer 1

up vote 2 down vote accepted

You can add a timer with call back to be called when your particle system is done.

...
particleSystem.addParticleModifier(new ExpireModifier(particleEffectDuration));
gameObject.getScene().attachChild(particleSystem);
scene.registerUpdateHandler(new TimerHandler(particleEffectDuration, new ITimerCallback() {
    @Override
    public void onTimePassed(final TimerHandler pTimerHandler) {
        //code that triggers when timer is complete
    }
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.