Added remove method to fully nuke a tween from the manager.

This commit is contained in:
Richard Davey 2019-03-15 10:30:50 +00:00
parent a799f5abf0
commit 0897b78f8a

View file

@ -4,6 +4,7 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var ArrayRemove = require('../utils/array/Remove');
var Class = require('../utils/Class');
var NumberTweenBuilder = require('./builders/NumberTweenBuilder');
var PluginCache = require('../plugins/PluginCache');
@ -374,6 +375,28 @@ var TweenManager = new Class({
}
},
/**
* Removes the given tween from the Tween Manager, regardless of its state (pending or active).
*
* @method Phaser.Tweens.TweenManager#remove
* @since 3.17.0
*
* @param {Phaser.Tweens.Tween} tween - The Tween to be removed.
*
* @return {Phaser.Tweens.TweenManager} This Tween Manager object.
*/
remove: function (tween)
{
ArrayRemove(this._add, tween);
ArrayRemove(this._pending, tween);
ArrayRemove(this._active, tween);
ArrayRemove(this._destroy, tween);
tween.state = TWEEN_CONST.REMOVED;
return this;
},
/**
* Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't.
*