瀏覽代碼

Changed AnimationState animation time so it continues past animation end if non-looping and animation end is >= animation duration.

This allows sequences to continue to play in the common case where animation end is not being used to stop the animation early.
Nathan Sweet 4 年之前
父節點
當前提交
f7ae127115
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java

+ 8 - 4
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java

@@ -1012,16 +1012,20 @@ public class AnimationState {
 			nextAnimationLast = animationLast;
 			nextAnimationLast = animationLast;
 		}
 		}
 
 
-		/** Uses {@link #getTrackTime()} to compute the <code>animationTime</code>, which is between {@link #getAnimationStart()}
-		 * and {@link #getAnimationEnd()}. When the <code>trackTime</code> is 0, the <code>animationTime</code> is equal to the
-		 * <code>animationStart</code> time. */
+		/** Uses {@link #getTrackTime()} to compute the <code>animationTime</code>. When the <code>trackTime</code> is 0, the
+		 * <code>animationTime</code> is equal to the <code>animationStart</code> time.
+		 * <p>
+		 * The <code>animationTime</code> is between {@link #getAnimationStart()} and {@link #getAnimationEnd()}, except if this
+		 * track entry is non-looping and {@link #getAnimationEnd()} is >= to the animation {@link Animation#duration}, then
+		 * <code>animationTime</code> continues to increase past {@link #getAnimationEnd()}. */
 		public float getAnimationTime () {
 		public float getAnimationTime () {
 			if (loop) {
 			if (loop) {
 				float duration = animationEnd - animationStart;
 				float duration = animationEnd - animationStart;
 				if (duration == 0) return animationStart;
 				if (duration == 0) return animationStart;
 				return (trackTime % duration) + animationStart;
 				return (trackTime % duration) + animationStart;
 			}
 			}
-			return Math.min(trackTime + animationStart, animationEnd);
+			float animationTime = trackTime + animationStart;
+			return animationEnd >= animation.duration ? animationTime : Math.min(animationTime, animationEnd);
 		}
 		}
 
 
 		/** Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or
 		/** Multiplier for the delta time when this track entry is updated, causing time for this animation to pass slower or