I was advised a while ago to use animation states rather than using animation.apply directly.
My problem is though that I was sending a keycode that would change the character's state(walking, jumping, standing).
I would then use this state to apply the appropriate animation like this:
if(character.getState().equals(State.WALKING)
runAnimation.apply(charSkeleton, lastTime, time, true, events);
Animation state's seem way simpler to use. How can I go about integrating these with my current character's states?
I tried to simply set the animation state according to the character's state. However, the running animation for example seems to play the first animation frame every frame continuously - resulting in an ice-skating like effect. Which makes sense, but isn't what I need. Is there a way to fire setAnimation() only once, say on a character's state change? Or possibly get the current animation so that it won't fire if the appropriate animation is already applied?
Edit:
After posting this I thought about using a flagging variable to check if the state was changed since the last frame, and it it was - firing the appropriate AnimationState. Seems simple enough, but is there a better way to go about this?