Skip to content

Commit 0436f1f

Browse files
committed
If you flagged a Tween as paused in its config, never started it, and then called Tween.stop it wouldn't ever be removed from the _pending array. It's now moved to the Tween Manager's destroy list, ready for removal on the next frame. Fix phaserjs#4023
1 parent b1771a1 commit 0436f1f

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ This change has been introduced for `pointerdown`, `pointerup`, `pointermove`, `
6363
* TileSprite.setTileScale would set the tile position by mistake, instead of the scale. Using the properties directly worked, but the method was incorrect (thanks @alexeymolchan)
6464
* Calling `Text.setStyle` would make the Text vanish if you didn't provide a `resolution` property in the style configuration object. Calling `setStyle` now only changes the properties given in the object, leaving any previously changed properties as-is. Fix #4011 (thanks @okcompewter)
6565
* In Matter.js if a body had its debug `render.visible` property set to `false` it wouldn't then render any other debug body beyond it. Now it will just skip bodies with hidden debug graphics (thanks @jf908)
66+
* If you flagged a Tween as `paused` in its config, never started it, and then called `Tween.stop` it wouldn't ever be removed from the `_pending` array. It's now moved to the Tween Manager's destroy list, ready for removal on the next frame. Fix #4023 (thanks @goldfire)
6667

6768
### Examples, Documentation and TypeScript
6869

6970
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
7071

71-
72+
@johanlindfors @Arthur3DLHC
7273

7374
## Version 3.12.0 - Silica - 4th September 2018
7475

src/tweens/TweenManager.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ var TweenManager = new Class({
275275

276276
var list = this._destroy;
277277
var active = this._active;
278+
var pending = this._pending;
278279
var i;
279280
var tween;
280281

@@ -286,7 +287,18 @@ var TweenManager = new Class({
286287
// Remove from the 'active' array
287288
var idx = active.indexOf(tween);
288289

289-
if (idx !== -1)
290+
if (idx === -1)
291+
{
292+
// Not in the active array, is it in pending instead?
293+
idx = pending.indexOf(tween);
294+
295+
if (idx > -1)
296+
{
297+
tween.state = TWEEN_CONST.REMOVED;
298+
pending.splice(idx, 1);
299+
}
300+
}
301+
else
290302
{
291303
tween.state = TWEEN_CONST.REMOVED;
292304
active.splice(idx, 1);

src/tweens/tween/Tween.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,12 @@ var Tween = new Class({
899899

900900
if (this.state !== TWEEN_CONST.REMOVED)
901901
{
902+
if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD)
903+
{
904+
this.parent._destroy.push(this);
905+
this.parent._toProcess++;
906+
}
907+
902908
this.state = TWEEN_CONST.PENDING_REMOVE;
903909
}
904910
},

0 commit comments

Comments
 (0)