Skip to content

Commit 084c423

Browse files
committed
Implementing PluginManager.remove function, added PluginManager.removeAll function.
1 parent 3f99b69 commit 084c423

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

src/core/PluginManager.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,36 @@ Phaser.PluginManager.prototype = {
130130
* @param {Phaser.Plugin} plugin - The plugin to be removed.
131131
*/
132132
remove: function (plugin) {
133+
134+
if (this._pluginsLength == 0)
135+
{
136+
return;
137+
}
133138

134-
// TODO
135-
this._pluginsLength--;
139+
for (this._p = 0; this._p < this._pluginsLength; this._p++)
140+
{
141+
if (this.plugins[this._p] === plugin)
142+
{
143+
plugin.destroy();
144+
this.plugins.splice(this._p, 1);
145+
this._pluginsLength--;
146+
return;
147+
}
148+
}
149+
},
136150

151+
/**
152+
* Removes all Plugins from the PluginManager.
153+
* @method Phaser.PluginManager#removeAll
154+
*/
155+
removeAll: function() {
156+
157+
for (this._p = 0; this._p < this._pluginsLength; this._p++)
158+
{
159+
this.plugins[this._p].destroy();
160+
}
161+
this.plugins.length = 0;
162+
this._pluginsLength = 0;
137163
},
138164

139165
/**

0 commit comments

Comments
 (0)