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

This commit is contained in:
Richard Davey 2018-09-12 14:54:08 +01:00
parent b1771a17dd
commit 0436f1ff6d
3 changed files with 21 additions and 2 deletions

View file

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

View file

@ -275,6 +275,7 @@ var TweenManager = new Class({
var list = this._destroy;
var active = this._active;
var pending = this._pending;
var i;
var tween;
@ -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);

View file

@ -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;
}
},