From 36c65618d7bd27016cf49e15d7290db1e611f8dd Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 3 Nov 2022 12:56:58 +0000 Subject: [PATCH] Safer seek loop --- src/tweens/tween/Tween.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tweens/tween/Tween.js b/src/tweens/tween/Tween.js index 692fc6e92..d4222e85d 100644 --- a/src/tweens/tween/Tween.js +++ b/src/tweens/tween/Tween.js @@ -496,11 +496,18 @@ var Tween = new Class({ if (amount > 0) { - do + var iterations = Math.floor(amount / delta); + var remainder = amount - (iterations * delta); + + for (var i = 0; i < iterations; i++) { this.update(delta); + } - } while (this.totalElapsed < amount); + if (remainder > 0) + { + this.update(remainder); + } } this.paused = isPaused;