diff --git a/src/core/Game.js b/src/core/Game.js index ca1a0635..9f4122ea 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -437,6 +437,7 @@ Phaser.Game.prototype = { this.plugins.update(); this.world.postUpdate(); + this.plugins.postUpdate(); this.renderer.render(this.stage._stage); this.plugins.render(); diff --git a/src/core/Plugin.js b/src/core/Plugin.js index 14cfc3d8..68a03029 100644 --- a/src/core/Plugin.js +++ b/src/core/Plugin.js @@ -50,6 +50,12 @@ Phaser.Plugin = function (game, parent) { * @default */ this.hasUpdate = false; + + /** + * @property {boolean} hasPostUpdate - A flag to indicate if this plugin has a postUpdate method. + * @default + */ + this.hasPostUpdate = false; /** * @property {boolean} hasRender - A flag to indicate if this plugin has a render method. diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index 98eaea40..932d7bab 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -77,6 +77,12 @@ Phaser.PluginManager.prototype = { result = true; } + if (typeof plugin['postUpdate'] === 'function') + { + plugin.hasPostUpdate = true; + result = true; + } + if (typeof plugin['render'] === 'function') { plugin.hasRender = true; @@ -176,6 +182,30 @@ Phaser.PluginManager.prototype = { }, + /** + * PostUpdate is the last thing to be called before the world render. + * In particular, it is called after the world postUpdate, which means the camera has been adjusted. + * It only calls plugins who have active=true. + * + * @method Phaser.PluginManager#postUpdate + */ + postUpdate: function () { + + if (this._pluginsLength == 0) + { + return; + } + + for (this._p = 0; this._p < this._pluginsLength; this._p++) + { + if (this.plugins[this._p].active && this.plugins[this._p].hasPostUpdate) + { + this.plugins[this._p].postUpdate(); + } + } + + }, + /** * Render is called right after the Game Renderer completes, but before the State.render. * It only calls plugins who have visible=true.