Skip to content

Commit

Permalink
Tweens created with a duration of zero will now render for one frame …
Browse files Browse the repository at this point in the history
…before completing. Fix #4235
  • Loading branch information
photonstorm committed Apr 8, 2019
1 parent b9fef30 commit cd8fb42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -92,6 +92,7 @@ Notes:
* `Utils.Array.Add` would act incorrectly when adding an object into an array in which it already belonged. This would manifest if, for example, adding a child into a display list it was already a part of. Fix #4411 (thanks @mudala @LoolzRules)
* `Tile.getCenterX` and `Tile.getCenterY` would return the wrong values for tiles on scaled layers. Fix #3845 (thanks @oloflarsson @florianvazelle)
* `Camera.startFollow` will now ensure that if the Camera is using bounds that the `scrollX` and `scrollY` values set after first following the Game Object do not exceed the bounds (thanks @snowbillr)
* Creating a Tween with a `duration` of zero would cause the tweened object properties to be set to `NaN`. Now they will tween for one single frame before being set to progress 1. Fix #4235 (thanks @BigZaphod)

### Examples, Documentation and TypeScript

Expand Down
7 changes: 5 additions & 2 deletions src/tweens/tween/Tween.js
Expand Up @@ -480,7 +480,10 @@ var Tween = new Class({
}

// Excludes loop values
this.duration = max;

// If duration has been set to 0 then we give it a super-low value so that it always
// renders at least 1 frame, but no more, without causing divided by zero errors elsewhere.
this.duration = Math.max(max, 0.001);

this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop;

Expand Down Expand Up @@ -515,7 +518,7 @@ var Tween = new Class({
var gen = tweenData.gen;

tweenData.delay = gen.delay(i, totalTargets, target);
tweenData.duration = gen.duration(i, totalTargets, target);
tweenData.duration = Math.max(gen.duration(i, totalTargets, target), 0.001);
tweenData.hold = gen.hold(i, totalTargets, target);
tweenData.repeat = gen.repeat(i, totalTargets, target);
tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target);
Expand Down

0 comments on commit cd8fb42

Please sign in to comment.