From ee6f277b319191b646e15701f2d8cb3c36b91c7a Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 3 Jun 2016 15:52:17 +0100 Subject: [PATCH] PluginManager.remove has a new argument `destroy` (defaults to `true`) which will let you optionally called the `destroy` method of the Plugin being removed. --- README.md | 1 + src/core/PluginManager.js | 11 +++++++++-- typescript/phaser.d.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fed4b6e5f..181dfe2c1 100644 --- a/README.md +++ b/README.md @@ -360,6 +360,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Stage has had all of its core update loops modified, so they now iterate through the display list forwards, instead of in reverse. Stage.postUpdate is now also a lot smaller, with no conditional branching if there is a Camera Target or not. * Within RequestAnimationFrame both `updateRAF` and `updateSetTimeout` now only call `game.update` if `isRunning` is true. This should avoid asynchronous Game destroy errors under environments like Angular (thanks @flogvit #2521) * Group.removeAll has a new argument `destroyTexture` which allows you to optionally destroy the BaseTexture of each child, as it is removed from the Group (thanks @stoneman1 #2487) +* PluginManager.remove has a new argument `destroy` (defaults to `true`) which will let you optionally called the `destroy` method of the Plugin being removed. ### Bug Fixes diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index f30969a66..bda008b08 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -131,8 +131,11 @@ Phaser.PluginManager.prototype = { * * @method Phaser.PluginManager#remove * @param {Phaser.Plugin} plugin - The plugin to be removed. + * @param {boolean} [destroy=true] - Call destroy on the plugin that is removed? */ - remove: function (plugin) { + remove: function (plugin, destroy) { + + if (destroy === undefined) { destroy = true; } this._i = this._len; @@ -140,7 +143,11 @@ Phaser.PluginManager.prototype = { { if (this.plugins[this._i] === plugin) { - plugin.destroy(); + if (destroy) + { + plugin.destroy(); + } + this.plugins.splice(this._i, 1); this._len--; return; diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts index f04f98c68..28b912387 100644 --- a/typescript/phaser.d.ts +++ b/typescript/phaser.d.ts @@ -3779,7 +3779,7 @@ declare module "phaser" { postRender(): void; postUpdate(): void; preUpdate(): void; - remove(plugin: Phaser.Plugin): void; + remove(plugin: Phaser.Plugin, destroy?: boolean): void; removeAll(): void; render(): void; update(): void;