I am trying to create an application using libgdx where i need an animation to be played on pressing an image button, i've been able to achieve it using this code
if(slapBossFlag==true) {
currentFrame = animation.getKeyFrame(timePassed, true);
batch.begin();
timePassed += Gdx.graphics.getDeltaTime();
Gdx.app.log("time","time is"+timePassed);
batch.draw(currentFrame, screenWidth / 2 - ((currentFrame.getRegionWidth()) / 2), screenHeight / 2 - ((currentFrame.getRegionHeight()) / 2));
batch.end();
slapBossFlag = false;
}
the problem is the animation goes by too quickly.
i've tried setting timePassed to zero when slapBossFlag is false, and that didnt work.
Can anyone help?