Tween.restart wouldn't restart the tween properly. Fix #4594

This commit is contained in:
Richard Davey 2019-06-19 11:05:27 +01:00
parent d71529b4c0
commit 8f22f37dca
2 changed files with 19 additions and 9 deletions

View file

@ -159,6 +159,7 @@ The following changes took place in the Pointer class:
* The `Arcade.StaticBody.setSize` arguments have changed from `(width, height, offsetX, offsetY)` to `(width, height, center)`. They now match Dynamic Body setSize and the Size Component method (thanks @samme) * The `Arcade.StaticBody.setSize` arguments have changed from `(width, height, offsetX, offsetY)` to `(width, height, center)`. They now match Dynamic Body setSize and the Size Component method (thanks @samme)
* When enabling Arcade Physics Body debug it will now draw only the faces marked for collision, allowing you to easily see if a face is disabled or not (thanks @BdR76) * When enabling Arcade Physics Body debug it will now draw only the faces marked for collision, allowing you to easily see if a face is disabled or not (thanks @BdR76)
* `Transform.getParentRotation` is a new method available to all GameObjects that will return the sum total rotation of all of the Game Objects parent Containers, if it has any. * `Transform.getParentRotation` is a new method available to all GameObjects that will return the sum total rotation of all of the Game Objects parent Containers, if it has any.
* `Tween.restart` now sets the Tween properties `elapsed`, `progress`, `totalElapsed` and `totalProgress` to zero when called, rather than adding to existing values should the tween already be running.
### Bug Fixes ### Bug Fixes
@ -181,6 +182,7 @@ The following changes took place in the Pointer class:
* `Arcade.StaticBody.setSize` now centers the body correctly, as with the other similar methods. Fix #4213 (thanks @samme) * `Arcade.StaticBody.setSize` now centers the body correctly, as with the other similar methods. Fix #4213 (thanks @samme)
* Setting `random: false` in a Particle Emitter config option no longer causes it to think random is true (thanks @samme) * Setting `random: false` in a Particle Emitter config option no longer causes it to think random is true (thanks @samme)
* `Zone.setSize` didn't update the displayOrigin, causing touch events to be inaccurate as the origin was out. Fix #4131 (thanks @rexrainbow) * `Zone.setSize` didn't update the displayOrigin, causing touch events to be inaccurate as the origin was out. Fix #4131 (thanks @rexrainbow)
* `Tween.restart` wouldn't restart the tween properly. Fix #4594 (thanks @NokFrt)
### Examples, Documentation and TypeScript ### Examples, Documentation and TypeScript

View file

@ -419,23 +419,31 @@ var Tween = new Class({
*/ */
restart: function () restart: function ()
{ {
if (this.state === TWEEN_CONST.PENDING_ADD) // Reset these so they're ready for the next update
{ this.elapsed = 0;
return this; this.progress = 0;
} this.totalElapsed = 0;
this.totalProgress = 0;
if (this.state === TWEEN_CONST.REMOVED) if (this.state === TWEEN_CONST.ACTIVE)
{
return this.seek(0);
}
else if (this.state === TWEEN_CONST.REMOVED)
{ {
this.seek(0); this.seek(0);
this.parent.makeActive(this); this.parent.makeActive(this);
return this;
}
else if (this.state === TWEEN_CONST.PENDING_ADD)
{
return this;
} }
else else
{ {
this.stop(); return this.play();
this.play();
} }
return this;
}, },
/** /**