Skip to content

Commit

Permalink
Skip preupdate/update for PIXI hierarchies in which an ancestor doesn…
Browse files Browse the repository at this point in the history
…'t exist
  • Loading branch information
cocoademon committed Nov 19, 2013
1 parent e435719 commit 7ef5ab8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/core/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 6 additions & 2 deletions src/gameobjects/Sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -371,7 +373,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
if (this.lifespan <= 0)
{
this.kill();
return;
return false;
}
}

Expand Down Expand Up @@ -399,6 +401,8 @@ Phaser.Sprite.prototype.preUpdate = function() {
this.body.preUpdate();
}

return true;

};

/**
Expand Down

0 comments on commit 7ef5ab8

Please sign in to comment.