From 645a6143267074a3550359dd7238989a14c48ddd Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 2 Jun 2016 22:45:31 +0100 Subject: [PATCH] Stage has had all of its core update loops modified, so they now iterate through the display list forwards, instead of in reverse. Stage.postUpdate is now also a lot smaller, with no conditional branching if there is a Camera Target or not. --- src/core/Stage.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/core/Stage.js b/src/core/Stage.js index aa5bd872c..69aca4783 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -145,7 +145,6 @@ Phaser.Stage.prototype.preUpdate = function () { this.currentRenderOrderID = 0; - // This can't loop in reverse, we need the orderID to be in sequence for (var i = 0; i < this.children.length; i++) { this.children[i].preUpdate(); @@ -160,9 +159,7 @@ Phaser.Stage.prototype.preUpdate = function () { */ Phaser.Stage.prototype.update = function () { - var i = this.children.length; - - while (i--) + for (var i = 0; i < this.children.length; i++) { this.children[i].update(); } @@ -173,22 +170,28 @@ Phaser.Stage.prototype.update = function () { * This is called automatically before the renderer runs and after the plugins have updated. * In postUpdate this is where all the final physics calculations and object positioning happens. * The objects are processed in the order of the display list. -* The only exception to this is if the camera is following an object, in which case that is updated first. * * @method Phaser.Stage#postUpdate */ Phaser.Stage.prototype.postUpdate = function () { - var i = this.children.length; + // Apply the camera shake, fade, bounds, etc + this.game.camera.update(); - while (i--) + for (var i = 0; i < this.children.length; i++) { this.children[i].postUpdate(); } this.updateTransform(); - this.game.world.camera.update(); + if (this.game.camera.target) + { + // The side-effect of this is that the Target may move into a tilemap + // (or colliding object?) and then get pushed out for one render pass + // which causes a weird jittering effect. + this.game.camera.updateTarget(); + } };