mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00: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:
parent
bcd31499c4
commit
1b5837d71d
4 changed files with 75 additions and 68 deletions
|
@ -86,6 +86,7 @@ Significant API changes:
|
|||
* BitmapData.addTo removed and enhanced BitmapData.add so it can accept either a single Sprite/Image or an Array of them.
|
||||
* BitmapData has had all of the EaselJS functions removed. It was just taking up space and you can do it all via BitmapData.context directly.
|
||||
* BitmapText has had a bit of an overhaul - the signature for adding a BitmapText has changed to: x, y, font, text, size. See the docs and examples for details.
|
||||
* World preUpdate, update and postUpdate have all been moved to Stage. So all children are updated regardless where on the display list they live.
|
||||
|
||||
|
||||
New features:
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue