Tweens created with a duration of zero will now render for one frame before completing. Fix #4235

This commit is contained in:
Richard Davey 2019-04-08 11:18:42 +01:00
parent b9fef30d99
commit cd8fb4217a
2 changed files with 6 additions and 2 deletions

View file

@ -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

View file

@ -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;
@ -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);