Skip to content

Commit

Permalink
If you flagged a Tween as paused in its config, never started it, a…
Browse files Browse the repository at this point in the history
…nd 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
  • Loading branch information
photonstorm committed Sep 12, 2018
1 parent b1771a1 commit 0436f1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ This change has been introduced for `pointerdown`, `pointerup`, `pointermove`, `
* 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)
* 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)
* 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)
* 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)

### Examples, Documentation and TypeScript

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:


@johanlindfors @Arthur3DLHC

## Version 3.12.0 - Silica - 4th September 2018

Expand Down
14 changes: 13 additions & 1 deletion src/tweens/TweenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ var TweenManager = new Class({

var list = this._destroy;
var active = this._active;
var pending = this._pending;
var i;
var tween;

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

if (idx !== -1)
if (idx === -1)
{
// Not in the active array, is it in pending instead?
idx = pending.indexOf(tween);

if (idx > -1)
{
tween.state = TWEEN_CONST.REMOVED;
pending.splice(idx, 1);
}
}
else
{
tween.state = TWEEN_CONST.REMOVED;
active.splice(idx, 1);
Expand Down
6 changes: 6 additions & 0 deletions src/tweens/tween/Tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,12 @@ var Tween = new Class({

if (this.state !== TWEEN_CONST.REMOVED)
{
if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD)
{
this.parent._destroy.push(this);
this.parent._toProcess++;
}

this.state = TWEEN_CONST.PENDING_REMOVE;
}
},
Expand Down

0 comments on commit 0436f1f

Please sign in to comment.