From 2650e2679d5992b98f00a63fc270f186791a14a0 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 12 Jan 2016 06:46:11 +0100 Subject: [PATCH] Apply remaining time to next animation. Previously one frame worth of delta time was lost. When the end of an animation is passed, one frame goes by so the animation has a chance to apply its final pose and fire any events on its last few frames. The second animation starts using the amount of time since the actual end of the first animation. #154 --- .../spine/AnimationState.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 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 913bc581d..dc1f43f10 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -64,21 +64,26 @@ public class AnimationState { TrackEntry current = tracks.get(i); if (current == null) continue; + TrackEntry next = current.next; + if (next != null) { + float nextTime = current.lastTime - next.delay; + if (nextTime >= 0) { + next.time = nextTime; + setCurrent(i, next); + current = next; + } + } else if (!current.loop && current.lastTime >= current.endTime) { + // End non-looping animation when it reaches its end time and there is no next entry. + clearTrack(i); + continue; + } + current.time += delta * current.timeScale; if (current.previous != null) { float previousDelta = delta * current.previous.timeScale; current.previous.time += previousDelta; current.mixTime += previousDelta; } - - TrackEntry next = current.next; - if (next != null) { - next.time = current.lastTime - next.delay; - if (next.time >= 0) setCurrent(i, next); - } else { - // End non-looping animation when it reaches its end time and there is no next entry. - if (!current.loop && current.lastTime >= current.endTime) clearTrack(i); - } } }