Fixed addAnimation when a non-looping animation trackTime is > duration.

The delay is based on `last.trackTime` because of how we preserve leftover time in update(). Previously using `addAnimation(..., 0)` on a track where the current animation has a trackTime > duration resulted in switching to the new animation, but the old animation trackTime was added to the new animation track time. See `float nextTime = current.trackLast - next.delay;` in update().
This commit is contained in:
NathanSweet 2018-03-27 17:22:47 +02:00
parent 75403b9e66
commit a961b41a9c

View File

@ -544,12 +544,12 @@ public class AnimationState {
float duration = last.animationEnd - last.animationStart; float duration = last.animationEnd - last.animationStart;
if (duration != 0) { if (duration != 0) {
if (last.loop) if (last.loop)
delay += duration * (1 + (int)(last.trackTime / duration)); delay += duration * (1 + (int)(last.trackTime / duration)); // Completion of next loop.
else else
delay += duration; delay += Math.max(duration, last.trackTime); // After duration, else next update.
delay -= data.getMix(last.animation, animation); delay -= data.getMix(last.animation, animation);
} else } else
delay = 0; delay = last.trackTime; // Next update.
} }
} }