Fixed issue where Image, Sprite, etc wouldn't call preUpdate or postUpdate of its children.

Fixed issue where renderOrderID wasn't being assigned correctly, causing the Input Handler to be unable to select the "top" item on a display list (would all default to zero)
Fixed issue where Stage would assign renderOrderIDs in reverse, should be in sequence.
Fixed issue where objects where checking World for the currentRenderOrderID by mistake instead of Stage.
Basically, input handling works a lot better now for Groups and nested objects :)
This commit is contained in:
photonstorm
2014-02-28 19:45:15 +00:00
parent 8dcfef8db0
commit 664d5b3e2c
14 changed files with 226 additions and 76 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ Phaser.BitmapText.prototype.preUpdate = function () {
if (this.visible)
{
this._cache[3] = this.game.world.currentRenderOrderID++;
this._cache[3] = this.game.stage.currentRenderOrderID++;
}
return true;
+1 -1
View File
@@ -102,7 +102,7 @@ Phaser.Graphics.prototype.preUpdate = function () {
if (this.visible)
{
this._cache[3] = this.game.world.currentRenderOrderID++;
this._cache[3] = this.game.stage.currentRenderOrderID++;
}
return true;
+14 -2
View File
@@ -134,7 +134,7 @@ Phaser.Image.prototype.preUpdate = function() {
if (!this.exists || !this.parent.exists)
{
this.renderOrderID = -1;
this._cache[3] = -1;
return false;
}
@@ -148,7 +148,13 @@ Phaser.Image.prototype.preUpdate = function() {
if (this.visible)
{
this._cache[3] = this.game.world.currentRenderOrderID++;
this._cache[3] = this.game.stage.currentRenderOrderID++;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].preUpdate();
}
return true;
@@ -185,6 +191,12 @@ Phaser.Image.prototype.postUpdate = function() {
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].postUpdate();
}
}
/**
+11 -3
View File
@@ -257,14 +257,15 @@ Phaser.Sprite.prototype.preUpdate = function() {
if (this.visible)
{
this._cache[3] = this.game.world.currentRenderOrderID++;
this._cache[3] = this.game.stage.currentRenderOrderID++;
}
this.animations.update();
if (this.body)
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
// this.body.preUpdate();
this.children[i].preUpdate();
}
return true;
@@ -273,6 +274,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
/**
* Override and use this function in your own custom objects to handle any update requirements you may have.
* Remember if this Sprite has any children you should call update on them too.
*
* @method Phaser.Sprite#update
* @memberof Phaser.Sprite
@@ -309,6 +311,12 @@ Phaser.Sprite.prototype.postUpdate = function() {
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].postUpdate();
}
};
/**
+13 -1
View File
@@ -148,7 +148,13 @@ Phaser.Text.prototype.preUpdate = function () {
if (this.visible)
{
this._cache[3] = this.game.world.currentRenderOrderID++;
this._cache[3] = this.game.stage.currentRenderOrderID++;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].preUpdate();
}
return true;
@@ -177,6 +183,12 @@ Phaser.Text.prototype.postUpdate = function () {
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].postUpdate();
}
}
/**
+17
View File
@@ -140,6 +140,17 @@ Phaser.TileSprite.prototype.preUpdate = function() {
this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;
}
if (this.visible)
{
this._cache[3] = this.game.stage.currentRenderOrderID++;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].preUpdate();
}
return true;
}
@@ -169,6 +180,12 @@ Phaser.TileSprite.prototype.postUpdate = function() {
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
}
// Update any Children
for (var i = 0, len = this.children.length; i < len; i++)
{
this.children[i].postUpdate();
}
}
/**