Error showing libGDX animation

2

When drawing the animation, just grab the first texture, do not go through the array and I do not know why ...

Here I leave the fragment of the render, when I call the animation

 if(juegoAcabado){
            // Si hi ha hagut col·lisió: Reproduïm l'explosió
            //stackOverflow EXPLOSION bucle
            sb.draw(explosionAnim.getKeyFrame(0, false), (nave.getPosition().x + nave.NAVE_ANCHO / 2) - 32, nave.getPosition().y + nave.NAVE_ALTO / 2 - 32, 64, 64);
    
asked by Iron Man 31.05.2018 в 12:33
source

1 answer

2

Probably the problem is in getKeyFrame (0, false) .

Look at the API of Animation The first parameter must be a float value with the time elapsed since the start of the animation.

If it is always zero then it will always show the first frame.

You will need to pass a float variable that counts the elapsed animation time. In the second parameter you probably want to use true for a loop animation.

    
answered by 31.05.2018 / 15:06
source