From a961b41a9c2c994aeca7d4b05dee440be6299bc8 Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Tue, 27 Mar 2018 17:22:47 +0200 Subject: [PATCH 1/2] 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. } } From c956bb4bc909060a5dfd4272f4b98b66734f0b3f Mon Sep 17 00:00:00 2001 From: John Date: Wed, 28 Mar 2018 18:37:33 +0800 Subject: [PATCH 2/2] [csharp] Fixed AddAnimation. Port of https://github.com/EsotericSoftware/spine-runtimes/commit/a961b41a9c2c994aeca7d4b05dee440be6299bc8. See: https://github.com/EsotericSoftware/spine-runtimes/issues/1092 --- spine-csharp/src/AnimationState.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 2abde4c6d..a2f826e4c 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -528,13 +528,13 @@ namespace Spine { 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. } }