mirror of
https://github.com/wassname/phaser.git
synced 2026-08-09 12:20:34 +08:00
World preUpdate, update and postUpdate have all been moved to Stage. So all children are updated regardless where on the display list they live. Fixes #419
This commit is contained in:
+2
-3
@@ -600,7 +600,7 @@ Phaser.Game.prototype = {
|
||||
}
|
||||
|
||||
this.plugins.preUpdate();
|
||||
this.world.preUpdate();
|
||||
this.stage.preUpdate();
|
||||
|
||||
this.stage.update();
|
||||
this.tweens.update();
|
||||
@@ -610,9 +610,8 @@ Phaser.Game.prototype = {
|
||||
this.physics.update();
|
||||
this.particles.update();
|
||||
this.plugins.update();
|
||||
this.world.update();
|
||||
|
||||
this.world.postUpdate();
|
||||
this.stage.postUpdate();
|
||||
this.plugins.postUpdate();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,78 @@ Phaser.Stage = function (game, width, height) {
|
||||
Phaser.Stage.prototype = Object.create(PIXI.Stage.prototype);
|
||||
Phaser.Stage.prototype.constructor = Phaser.Stage;
|
||||
|
||||
/**
|
||||
* This is called automatically after the plugins preUpdate and before the State.update.
|
||||
* Most objects have preUpdate methods and it's where initial movement and positioning is done.
|
||||
*
|
||||
* @method Phaser.Stage#preUpdate
|
||||
*/
|
||||
Phaser.Stage.prototype.preUpdate = function () {
|
||||
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while(i--)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called automatically after the State.update, but before particles or plugins update.
|
||||
*
|
||||
* @method Phaser.Stage#update
|
||||
*/
|
||||
Phaser.Stage.prototype.update = function () {
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while(i--)
|
||||
{
|
||||
this.children[i].update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called automatically before the renderer runs and after the plugins have updated.
|
||||
* In postUpdate this is where all the final physics calculatations and object positioning happens.
|
||||
* The objects are processed in the order of the display list.
|
||||
* The only exception to this is if the camera is following an object, in which case that is updated first.
|
||||
*
|
||||
* @method Phaser.Stage#postUpdate
|
||||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
||||
if (this.game.world.camera.target)
|
||||
{
|
||||
this.game.world.camera.target.postUpdate();
|
||||
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while(i-- && this.children[i] !== this.game.world.camera.target)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.game.world.camera.update();
|
||||
|
||||
var i = this.children.length;
|
||||
|
||||
while(i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a Game configuration object.
|
||||
*
|
||||
|
||||
@@ -62,71 +62,6 @@ Phaser.World.prototype.boot = function () {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called automatically after the plugins preUpdate and before the State.update.
|
||||
* Most objects have preUpdate methods and it's where initial movement and positioning is done.
|
||||
*
|
||||
* @method Phaser.World#preUpdate
|
||||
*/
|
||||
Phaser.World.prototype.preUpdate = function () {
|
||||
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
for (var i = this.children.length - 1; i >= 0; i--)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called automatically after the State.update, but before particles or plugins update.
|
||||
* Most objects won't have an update method set unless explicitly given one.
|
||||
*
|
||||
* @method Phaser.World#update
|
||||
*/
|
||||
Phaser.World.prototype.update = function () {
|
||||
|
||||
for (var i = this.children.length - 1; i >= 0; i--)
|
||||
{
|
||||
this.children[i].update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called automatically before the renderer runs and after the plugins have updated.
|
||||
* In postUpdate this is where all the final physics calculatations and object positioning happens.
|
||||
* The objects are processed in the order of the display list.
|
||||
* The only exception to this is if the camera is following an object, in which case that is updated first.
|
||||
*
|
||||
* @method Phaser.World#postUpdate
|
||||
*/
|
||||
Phaser.World.prototype.postUpdate = function () {
|
||||
|
||||
if (this.camera.target && this.camera.target['postUpdate'])
|
||||
{
|
||||
this.camera.target.postUpdate();
|
||||
|
||||
this.camera.update();
|
||||
|
||||
for (var i = this.children.length - 1; i >= 0; i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.camera.update();
|
||||
|
||||
for (var i = this.children.length - 1; i >= 0; i--)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user