1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Roy T. Jun 8 '12 at 10:57
  • \$\begingroup\$ Thanks for you response, I modified my question as per you say. \$\endgroup\$ – Siddharth Jun 8 '12 at 11:03
  • \$\begingroup\$ What framework are you using? Some sort of Java + OpenGL thingey? \$\endgroup\$ – Roy T. Jun 8 '12 at 11:52
  • 1
    \$\begingroup\$ I was using andengine GLES1 that thing was mentioned after the question. \$\endgroup\$ – Siddharth Jun 8 '12 at 12:16
2
\$\begingroup\$

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
    }
});
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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