From 94e6e415184cc95df319de67f2d0302354247025 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Tue, 5 May 2020 15:34:07 +0200 Subject: [PATCH] Added AnimationState setNext and clearNext. http://esotericsoftware.com/forum/Keep-track-of-added-animations-13896 --- .../com/esotericsoftware/spine/AnimationState.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 8a23933f6..b8c37ce0e 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -522,6 +522,11 @@ public class AnimationState { queue.drain(); } + /** Removes the {@link TrackEntry#getNext() next entry} and all entries after it for the specified entry. */ + public void clearNext (TrackEntry entry) { + disposeNext(entry.next); + } + private void setCurrent (int index, TrackEntry current, boolean interrupt) { TrackEntry from = expandToIndex(index); tracks.set(index, current); @@ -1084,11 +1089,17 @@ public class AnimationState { this.drawOrderThreshold = drawOrderThreshold; } - /** The animation queued to start after this animation, or null. next makes up a linked list. */ + /** The animation queued to start after this animation, or null if there is none. next makes up a linked list. + * It cannot be set to null, use {@link AnimationState#clearNext(TrackEntry)} instead. */ public @Null TrackEntry getNext () { return next; } + public void setNext (TrackEntry next) { + if (next == null) throw new IllegalArgumentException("next cannot be null."); + this.next = next; + } + /** Returns true if at least one loop has been completed. *

* See {@link AnimationStateListener#complete(TrackEntry)}. */