diff --git a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTest.java b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTest.java index 0ea6c62a6..f9693d8fe 100644 --- a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTest.java +++ b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTest.java @@ -655,7 +655,7 @@ public class AnimationStateTest { } }); - setup("resetTrack", // 24 + setup("setEmptyAnimation", // 24 expect(0, "start", 0, 0), // expect(0, "event 0", 0, 0), // expect(0, "event 14", 0.5f, 0.5f), // @@ -665,7 +665,7 @@ public class AnimationStateTest { state.addAnimation(0, "events1", false, 0); run(0.1f, 10, new TestListener() { public void frame (float time) { - if (MathUtils.isEqual(time, 0.7f)) state.resetTrack(0, 0); + if (MathUtils.isEqual(time, 0.7f)) state.setEmptyAnimation(0, 0); } }); 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 45092b930..f0e0e85bc 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -269,26 +269,6 @@ public class AnimationState { queue.drain(); } - /** Removes all queued animations for all tracks and sets empty animations to mix out the current animations, so any changes - * the current animations have made to skeletons are reverted to the setup pose. */ - public void resetTracks (float mixDuration) { - queue.drainDisabled = true; - for (int i = 0, n = tracks.size; i < n; i++) - resetTrack(i, mixDuration); - queue.drainDisabled = false; - queue.drain(); - } - - /** Removes all queued animations and sets an empty animation to mix out the current animation, so any changes the current - * animation has made to skeletons are reverted to the setup pose. */ - public void resetTrack (int trackIndex, float mixDuration) { - if (trackIndex >= tracks.size) return; - TrackEntry current = tracks.get(trackIndex); - if (current == null) return; - setEmptyAnimation(current.trackIndex, mixDuration); - queue.drain(); - } - /** @param entry May be null. */ private void disposeNext (TrackEntry entry) { TrackEntry next = entry.next; @@ -383,7 +363,7 @@ public class AnimationState { /** Sets the current animation for a track, discarding any queued animations. * @return A track entry to allow further customization of animation playback. References to the track entry must not be kept - * after {@link AnimationStateListener#end(TrackEntry)}. */ + * after {@link AnimationStateListener#dispose(TrackEntry)}. */ public TrackEntry setAnimation (int trackIndex, Animation animation, boolean loop) { if (animation == null) throw new IllegalArgumentException("animation cannot be null."); TrackEntry current = expandToIndex(trackIndex); @@ -412,10 +392,10 @@ public class AnimationState { } /** Adds an animation to be played after the current or last queued animation for a track. - * @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use duration of the - * previous animation minus any mix duration plus the negative delay. + * @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation + * duration of the previous track minus any mix duration plus the negative delay. * @return A track entry to allow further customization of animation playback. References to the track entry must not be kept - * after {@link AnimationStateListener#end(TrackEntry)}. */ + * after {@link AnimationStateListener#dispose(TrackEntry)}. */ public TrackEntry addAnimation (int trackIndex, Animation animation, boolean loop, float delay) { if (animation == null) throw new IllegalArgumentException("animation cannot be null."); @@ -445,6 +425,7 @@ public class AnimationState { return entry; } + /** Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration. */ public TrackEntry setEmptyAnimation (int trackIndex, float mixDuration) { TrackEntry entry = setAnimation(trackIndex, emptyAnimation, false); entry.mixDuration = mixDuration; @@ -452,6 +433,12 @@ public class AnimationState { return entry; } + /** Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the + * specified mix duration. + * @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation + * duration of the previous track minus any mix duration plus the negative delay. + * @return A track entry to allow further customization of animation playback. References to the track entry must not be kept + * after {@link AnimationStateListener#dispose(TrackEntry)}. */ public TrackEntry addEmptyAnimation (int trackIndex, float mixDuration, float delay) { TrackEntry entry = addAnimation(trackIndex, emptyAnimation, false, delay); entry.mixDuration = mixDuration; @@ -459,6 +446,18 @@ public class AnimationState { return entry; } + /** Sets an empty animation for every tracks, discarding any queued animations, and mixes to it over the specified mix + * duration. */ + public void setEmptyAnimations (float mixDuration) { + queue.drainDisabled = true; + for (int i = 0, n = tracks.size; i < n; i++) { + TrackEntry current = tracks.get(i); + if (current != null) setEmptyAnimation(current.trackIndex, mixDuration); + } + queue.drainDisabled = false; + queue.drain(); + } + /** @param last May be null. */ private TrackEntry trackEntry (int trackIndex, Animation animation, boolean loop, TrackEntry last) { TrackEntry entry = trackEntryPool.obtain(); diff --git a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java index 3ccd74708..01280a876 100644 --- a/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java +++ b/spine-libgdx/spine-skeletonviewer/src/com/esotericsoftware/spine/SkeletonViewer.java @@ -503,7 +503,7 @@ public class SkeletonViewer extends ApplicationAdapter { if (state != null) { String name = animationList.getSelected(); if (name == null) - state.resetTrack(0, ui.mixSlider.getValue()); + state.setEmptyAnimation(0, ui.mixSlider.getValue()); else setAnimation(); }