Skip to content

Commit ec19abb

Browse files
committed
Component preUpdate changes.
1 parent 3d399f1 commit ec19abb

6 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/core/Game.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ Phaser.Game.prototype = {
781781
this.currentUpdateID = count;
782782

783783
this.updateLogic(1.0 / this.time.desiredFps);
784-
// Sync the scene graph after _every_ logic update to account for moved game objects
784+
785+
// Sync the scene graph after _every_ logic update to account for moved game objects
785786
this.stage.updateTransform();
786787

787788
count++;

src/gameobjects/Sprite.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ Phaser.Sprite = function (game, x, y, key, frame) {
6666
Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype);
6767
Phaser.Sprite.prototype.constructor = Phaser.Sprite;
6868

69+
Phaser.Sprite.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate;
70+
Phaser.Sprite.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate;
71+
Phaser.Sprite.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate;
72+
Phaser.Sprite.prototype.preUpdateCore = Phaser.Component.Core.preUpdate;
73+
6974
/**
7075
* Automatically called by World.preUpdate.
7176
*
@@ -75,11 +80,11 @@ Phaser.Sprite.prototype.constructor = Phaser.Sprite;
7580
*/
7681
Phaser.Sprite.prototype.preUpdate = function() {
7782

78-
Phaser.Component.PhysicsBody.preUpdate.call(this);
79-
Phaser.Component.LifeSpan.preUpdate.call(this);
80-
Phaser.Component.InWorld.preUpdate.call(this);
81-
Phaser.Component.Core.preUpdate.call(this);
83+
if (!this.preUpdatePhysics() || !this.preUpdateLifeSpan() || !this.preUpdateInWorld())
84+
{
85+
return false;
86+
}
8287

83-
return true;
88+
return this.preUpdateCore();
8489

8590
};

src/gameobjects/components/Core.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ Phaser.Component.Core = function () {};
22

33
Phaser.Component.Core.install = function (components) {
44

5-
// console.log('install', this);
6-
75
this.components = {};
86

97
for (var i = 0; i < components.length; i++)
@@ -41,8 +39,6 @@ Phaser.Component.Core.init = function (game, x, y, key, frame) {
4139
this.loadTexture(key, frame);
4240
}
4341

44-
// console.log('init', this);
45-
4642
};
4743

4844
Phaser.Component.Core.preUpdate = function () {
@@ -56,6 +52,7 @@ Phaser.Component.Core.preUpdate = function () {
5652
return false;
5753
}
5854

55+
console.log(this.world.y, this.worldTransform.ty);
5956
this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty);
6057

6158
if (this.visible)
@@ -78,6 +75,8 @@ Phaser.Component.Core.preUpdate = function () {
7875
this.children[i].preUpdate();
7976
}
8077

78+
return true;
79+
8180
};
8281

8382
Phaser.Component.Core.prototype = {

src/gameobjects/components/InWorld.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Phaser.Component.InWorld.preUpdate = function () {
4747
}
4848
}
4949

50+
return true;
51+
5052
};
5153

5254
Phaser.Component.InWorld.prototype = {

src/gameobjects/components/LifeSpan.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Phaser.Component.LifeSpan.preUpdate = function () {
1313
}
1414
}
1515

16+
return true;
17+
1618
};
1719

1820
Phaser.Component.LifeSpan.prototype = {

src/gameobjects/components/PhysicsBody.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Phaser.Component.PhysicsBody.preUpdate = function () {
3030
return false;
3131
}
3232

33+
return true;
34+
3335
};
3436

3537
Phaser.Component.PhysicsBody.postUpdate = function () {

0 commit comments

Comments
 (0)