mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Merge pull request #160 from cocoademon/camera_shake
Add a postUpdate function to plugins
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user