Bläddra i källkod

[ts] Port of commit 88b009c: AnimationState, improved triggering complete event.

Davide Tantillo 1 år sedan
förälder
incheckning
107f5ca5e6
1 ändrade filer med 8 tillägg och 3 borttagningar
  1. 8 3
      spine-ts/spine-core/src/AnimationState.ts

+ 8 - 3
spine-ts/spine-core/src/AnimationState.ts

@@ -436,9 +436,14 @@ export class AnimationState {
 
 		// Queue complete if completed a loop iteration or the animation.
 		let complete = false;
-		if (entry.loop)
-			complete = duration == 0 || trackLastWrapped > entry.trackTime % duration;
-		else
+		if (entry.loop) {
+			if (duration == 0)
+				complete = true;
+			else {
+				const cycles = Math.floor(entry.trackTime / duration);
+				complete = cycles > 0 && cycles > Math.floor(entry.trackTime / duration);
+			}
+		} else
 			complete = animationTime >= animationEnd && entry.animationLast < animationEnd;
 		if (complete) this.queue.complete(entry);