From a961b41a9c2c994aeca7d4b05dee440be6299bc8 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 27 Mar 2018 17:22:47 +0200 Subject: [PATCH] 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(). --- .../src/com/esotericsoftware/spine/AnimationState.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java index 32b215146..fa82e89f5 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -544,12 +544,12 @@ public class AnimationState { float duration = last.animationEnd - last.animationStart; if (duration != 0) { if (last.loop) - delay += duration * (1 + (int)(last.trackTime / duration)); + delay += duration * (1 + (int)(last.trackTime / duration)); // Completion of next loop. else - delay += duration; + delay += Math.max(duration, last.trackTime); // After duration, else next update. delay -= data.getMix(last.animation, animation); } else - delay = 0; + delay = last.trackTime; // Next update. } }