I have class which extends Actor. My animations are in 'act' method with stateTime timer. Below is fragment of this class:
@Override
public void act(float delta) {
super.act(delta);
stateTime += delta;
if(!isDeath) {
...
} else {
if(!animationDead.isAnimationFinished(stateTime)){
textureRegion = animationDead.getKeyFrame(stateTime, true);
}
}
}
animationDead has PLAYMODE.NORMAL
I'm trying to use '!animationDead.isAnimationFinished(stateTime)' but it's stoping my animation after first frame. I would like to stop animation after last frame.
Also i'm trying to set stateTime = 0; but the same, stopping after first frame.
The same situation i have when i press for example SPACE key my 'actor' should play fight animation. But for all frames of fight animaton i have to hold space key. One tap space is one frame of animation.
Here is fragment of this method:
@Override
public void act(float delta) {
super.act(delta);
stateTime += delta;
if(!isAttacking()) {
...
/* Keyboard events */
...
setAttacking(false);
if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
setAttacking(true);
if (moveToRight) {
textureRegion = animationAttack.getKeyFrame(stateTime,true);
} else if (!moveToRight) {
isPlayerFlippedToLeft = true;
textureRegion = animationAttack.getKeyFrame(stateTime,true);
}
setPlayerWidthAndHeight();
}