Merge pull request #210 from cocoademon/skip_pixi_updates

Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist
This commit is contained in:
Richard Davey
2013-11-19 04:20:17 -08:00
2 changed files with 17 additions and 6 deletions
+11 -4
View File
@@ -72,24 +72,31 @@ Phaser.World.prototype.boot = function () {
Phaser.World.prototype.update = function () {
this.currentRenderOrderID = 0;
if (this.game.stage._stage.first._iNext)
{
var currentNode = this.game.stage._stage.first._iNext;
var skipChildren = false;
do
{
if (currentNode['preUpdate'])
{
currentNode.preUpdate();
skipChildren = (currentNode.preUpdate() == false);
}
if (currentNode['update'])
{
currentNode.update();
skipChildren = (currentNode.update() == false) || skipChildren;
}
currentNode = currentNode._iNext;
if(skipChildren)
{
currentNode = currentNode.last._iNext;
} else {
currentNode = currentNode._iNext;
}
}
while (currentNode != this.game.stage._stage.last._iNext)
}
+6 -2
View File
@@ -361,7 +361,9 @@ Phaser.Sprite.prototype.preUpdate = function() {
if (!this.exists || (this.group && !this.group.exists))
{
this.renderOrderID = -1;
return;
// Skip children if not exists
return false;
}
if (this.lifespan > 0)
@@ -371,7 +373,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
if (this.lifespan <= 0)
{
this.kill();
return;
return false;
}
}
@@ -399,6 +401,8 @@ Phaser.Sprite.prototype.preUpdate = function() {
this.body.preUpdate();
}
return true;
};
/**