[libgdx] AnimationState, improved triggering complete event.

This commit is contained in:
Nathan Sweet 2024-03-20 10:46:44 -04:00
parent 94d8a3a387
commit 88b009cd1f

View File

@ -483,9 +483,14 @@ public class AnimationState {
// Queue complete if completed a loop iteration or the animation. // Queue complete if completed a loop iteration or the animation.
boolean complete; boolean complete;
if (entry.loop) if (entry.loop) {
complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; if (duration == 0)
else complete = true;
else {
int cycles = (int)(entry.trackTime / duration);
complete = cycles > 0 && cycles > (int)(entry.trackLast / duration);
}
} else
complete = animationTime >= animationEnd && entry.animationLast < animationEnd; complete = animationTime >= animationEnd && entry.animationLast < animationEnd;
if (complete) queue.complete(entry); if (complete) queue.complete(entry);