Skip to content

Commit 7ef5ab8

Browse files
committed
Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist
1 parent e435719 commit 7ef5ab8

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/core/World.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,31 @@ Phaser.World.prototype.boot = function () {
7272
Phaser.World.prototype.update = function () {
7373

7474
this.currentRenderOrderID = 0;
75-
75+
7676
if (this.game.stage._stage.first._iNext)
7777
{
7878
var currentNode = this.game.stage._stage.first._iNext;
79+
var skipChildren = false;
7980

8081
do
8182
{
8283
if (currentNode['preUpdate'])
8384
{
84-
currentNode.preUpdate();
85+
skipChildren = (currentNode.preUpdate() == false);
8586
}
8687

8788
if (currentNode['update'])
8889
{
89-
currentNode.update();
90+
skipChildren = (currentNode.update() == false) || skipChildren;
9091
}
9192

92-
currentNode = currentNode._iNext;
93+
if(skipChildren)
94+
{
95+
currentNode = currentNode.last._iNext;
96+
} else {
97+
currentNode = currentNode._iNext;
98+
}
99+
93100
}
94101
while (currentNode != this.game.stage._stage.last._iNext)
95102
}

src/gameobjects/Sprite.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ Phaser.Sprite.prototype.preUpdate = function() {
361361
if (!this.exists || (this.group && !this.group.exists))
362362
{
363363
this.renderOrderID = -1;
364-
return;
364+
365+
// Skip children if not exists
366+
return false;
365367
}
366368

367369
if (this.lifespan > 0)
@@ -371,7 +373,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
371373
if (this.lifespan <= 0)
372374
{
373375
this.kill();
374-
return;
376+
return false;
375377
}
376378
}
377379

@@ -399,6 +401,8 @@ Phaser.Sprite.prototype.preUpdate = function() {
399401
this.body.preUpdate();
400402
}
401403

404+
return true;
405+
402406
};
403407

404408
/**

0 commit comments

Comments
 (0)