Skip to content

Commit ded1320

Browse files
committed
Fixed issue with multiple calls to Tween.restart
1 parent 94fad47 commit ded1320

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Notes:
9898
* 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)
9999
* The First frame of a Texture would take on the appearance of the second frame in a Sprite Sheet created from trimmed Texture Atlas frames. Fix #4088 (thanks @Cirras)
100100
* `Tween.stop` assumed that the parent was the TweenManager. If the Tween has been added to the Timeline, that was not true and the stop method crashed (thanks @TadejZupancic)
101+
* Calling `Tween.restart` multiple times in a row would cause the tween to freeze. It will now disregard all additional calls to `restart` if it's already in a pending state (thanks @rgk)
101102

102103
### Examples, Documentation and TypeScript
103104

src/tweens/tween/Tween.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ var Tween = new Class({
419419
*/
420420
restart: function ()
421421
{
422+
if (this.state === TWEEN_CONST.PENDING_ADD)
423+
{
424+
return this;
425+
}
426+
422427
if (this.state === TWEEN_CONST.REMOVED)
423428
{
424429
this.seek(0);
@@ -926,7 +931,7 @@ var Tween = new Class({
926931
* @method Phaser.Tweens.Tween#stop
927932
* @since 3.0.0
928933
*
929-
* @param {number} [resetTo] - If you want to seek the tween, provide an value between 0 and 1.
934+
* @param {number} [resetTo] - If you want to seek the tween, provide a value between 0 and 1.
930935
*
931936
* @return {this} This Tween instance.
932937
*/

0 commit comments

Comments
 (0)