PluginManager.remove has a new argument destroy (defaults to true) which will let you optionally called the destroy method of the Plugin being removed.

This commit is contained in:
photonstorm 2016-06-03 15:52:17 +01:00
parent c73ccfbddb
commit ee6f277b31
3 changed files with 11 additions and 3 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;