From 084c4239e51bccacf520ffb75c85a6ddd56a19bc Mon Sep 17 00:00:00 2001 From: Samuel Batista Date: Fri, 8 Nov 2013 01:11:36 -0500 Subject: [PATCH] Implementing PluginManager.remove function, added PluginManager.removeAll function. --- src/core/PluginManager.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index 932d7bab..0323b21a 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -130,10 +130,36 @@ Phaser.PluginManager.prototype = { * @param {Phaser.Plugin} plugin - The plugin to be removed. */ remove: function (plugin) { + + if (this._pluginsLength == 0) + { + return; + } - // TODO - this._pluginsLength--; + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p] === plugin) + { + plugin.destroy(); + this.plugins.splice(this._p, 1); + this._pluginsLength--; + return; + } + } + }, + /** + * Removes all Plugins from the PluginManager. + * @method Phaser.PluginManager#removeAll + */ + removeAll: function() { + + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + this.plugins[this._p].destroy(); + } + this.plugins.length = 0; + this._pluginsLength = 0; }, /**