From 0897b78f8a0e96a2b925af6af3b6c3f221dd9f4f Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 15 Mar 2019 10:30:50 +0000 Subject: [PATCH] Added remove method to fully nuke a tween from the manager. --- src/tweens/TweenManager.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/tweens/TweenManager.js b/src/tweens/TweenManager.js index 026873476..e9a241f46 100644 --- a/src/tweens/TweenManager.js +++ b/src/tweens/TweenManager.js @@ -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. *