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.

This commit is contained in:
Richard Davey 2016-06-02 22:45:31 +01:00
parent c822cda452
commit 645a614326

View file

@ -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();
}
};