From f00c52598b91bae52600e8c5ee211f8a6583b452 Mon Sep 17 00:00:00 2001 From: beeglebug Date: Sun, 27 Oct 2013 22:30:01 +0000 Subject: [PATCH] added init method to plugins this will allow potentially destructive code to run outside of the constructor, and only if it has been added to the PluginManager --- src/core/PluginManager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index 29e49fd6..98eaea40 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -103,6 +103,13 @@ Phaser.PluginManager.prototype = { } this._pluginsLength = this.plugins.push(plugin); + + // Allows plugins to run potentially destructive code outside of the constructor, and only if being added to the PluginManager + if (typeof plugin['init'] === 'function') + { + plugin.init(); + } + return plugin; } else