Pharan schriebI've tried playing animations backwards with AnimationState by setting the timeScale of the SpineAnimation component to a negative number. It didn't work (despite what Nate said).
Ah, right. AnimationState expects the times to increment, eg for queuing and mixing. I played with accepting a negative delta but it wasn't clean. The best I came up with was a separate method (or boolean checks in apply) like this:
public void applyBackward (Skeleton skeleton) {
if (current == null) return;
if (previous != null) {
previous.apply(skeleton, previous.getDuration() - (previousTime % previous.getDuration()), previousLoop);
float alpha = mixTime / mixDuration;
if (alpha >= 1) {
alpha = 1;
previous = null;
}
current.mix(skeleton, current.getDuration() - (currentTime % current.getDuration()), currentLoop, alpha);
} else
current.apply(skeleton, current.getDuration() - (currentTime % current.getDuration()), currentLoop);
}
The only issue with this is that you can't switch smoothly from backward to forward. If you stop calling apply and begin calling applyBackward, there will be a jump in your animation because the times will be interpreted differently. This is not the same as calling with a positive delta and then a negative delta (if negative delta were supported).
So, I don't think there is a clean solution to playing animations backwards using AnimationState, sorry!