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; + }; /**