2

Is there a way to get the time until completion of a ParticleEffect in libgdx? For example, say I want something to happen one second before the ParticleEffect completes:

private void foo(){
    ParticleEffect bombEffect = new ParticleEffect();
    bombEffect.load(Gdx.files.internal("particles/bomb.p"), atlas);
    .
    .
    .
    if(timeToCompletion(bombEffect) < 1){ 
        // do something
    }
    .
    .
    . 
}

private float timeToCompletion(ParticleEffect pEffect){
    // How can this be implemented??
}
asherbret
  • 5,439
  • 4
  • 38
  • 58

1 Answers1

0

You know the duration of particle effect. Than you can count time in some variable. And than check if duration - thistime < 1. Maybe this is not the best solution, but it will work.

One more idea is to extend your own class from ParticleEffect and implement this functionality there, and you will be able to call something like yourEffect.getPassedTime ();

Hope this will be useful for you. Good luck.

Aleksandrs
  • 1,488
  • 1
  • 14
  • 34