From 7ef5ab8c98f51a583d8a534ff8705e410d03f7b6 Mon Sep 17 00:00:00 2001 From: Cameron Foale Date: Tue, 19 Nov 2013 16:29:02 +1100 Subject: [PATCH] Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist --- src/core/World.js | 15 +++++++++++---- src/gameobjects/Sprite.js | 8 ++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/core/World.js b/src/core/World.js index 3f2d4609..6d6938bf 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -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) } diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 81ba258b..33894485 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -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; + }; /**