Optimised preUpdate callbacks.

This commit is contained in:
photonstorm 2015-02-25 02:49:50 +00:00
parent ee48675a28
commit ae7a1fda05
4 changed files with 40 additions and 16 deletions

View file

@ -59,6 +59,9 @@ Phaser.Image = function (game, x, y, key, frame) {
Phaser.Image.prototype = Object.create(PIXI.Sprite.prototype);
Phaser.Image.prototype.constructor = Phaser.Image;
Phaser.Image.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
Phaser.Image.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
/**
* Automatically called by World.preUpdate.
*
@ -67,9 +70,11 @@ Phaser.Image.prototype.constructor = Phaser.Image;
*/
Phaser.Image.prototype.preUpdate = function() {
Phaser.Component.InWorld.preUpdate.call(this);
Phaser.Component.Core.preUpdate.call(this);
if (!this.preUpdateInWorld())
{
return false;
}
return true;
return this.preUpdateCore();
};

View file

@ -75,6 +75,11 @@ Phaser.Rope = function (game, x, y, key, frame, points) {
Phaser.Rope.prototype = Object.create(PIXI.Rope.prototype);
Phaser.Rope.prototype.constructor = Phaser.Rope;
Phaser.Rope.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate;
Phaser.Rope.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate;
Phaser.Rope.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
Phaser.Rope.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
/**
* Automatically called by World.preUpdate.
*
@ -93,12 +98,12 @@ Phaser.Rope.prototype.preUpdate = function() {
this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;
}
Phaser.Component.PhysicsBody.preUpdate.call(this);
Phaser.Component.LifeSpan.preUpdate.call(this);
Phaser.Component.InWorld.preUpdate.call(this);
Phaser.Component.Core.preUpdate.call(this);
if (!this.preUpdatePhysics() || !this.preUpdateLifeSpan() || !this.preUpdateInWorld())
{
return false;
}
return true;
return this.preUpdateCore();
};

View file

@ -87,7 +87,9 @@ Phaser.Text = function (game, x, y, text, style) {
'FixedToCamera',
'InputEnabled',
'InWorld',
'LifeSpan',
'Overlap',
'PhysicsBody',
'Reset',
'Smoothed'
];
@ -105,6 +107,11 @@ Phaser.Text = function (game, x, y, text, style) {
Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
Phaser.Text.prototype.constructor = Phaser.Text;
Phaser.Text.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate;
Phaser.Text.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate;
Phaser.Text.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
Phaser.Text.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
/**
* Automatically called by World.preUpdate.
*
@ -113,10 +120,12 @@ Phaser.Text.prototype.constructor = Phaser.Text;
*/
Phaser.Text.prototype.preUpdate = function () {
Phaser.Component.InWorld.preUpdate.call(this);
Phaser.Component.Core.preUpdate.call(this);
if (!this.preUpdatePhysics() || !this.preUpdateLifeSpan() || !this.preUpdateInWorld())
{
return false;
}
return true;
return this.preUpdateCore();
};

View file

@ -68,6 +68,11 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
Phaser.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype);
Phaser.TileSprite.prototype.constructor = Phaser.TileSprite;
Phaser.TileSprite.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate;
Phaser.TileSprite.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate;
Phaser.TileSprite.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
Phaser.TileSprite.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
/**
* Automatically called by World.preUpdate.
*
@ -86,12 +91,12 @@ Phaser.TileSprite.prototype.preUpdate = function() {
this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;
}
Phaser.Component.PhysicsBody.preUpdate.call(this);
Phaser.Component.LifeSpan.preUpdate.call(this);
Phaser.Component.InWorld.preUpdate.call(this);
Phaser.Component.Core.preUpdate.call(this);
if (!this.preUpdatePhysics() || !this.preUpdateLifeSpan() || !this.preUpdateInWorld())
{
return false;
}
return true;
return this.preUpdateCore();
};