Skip to content

Commit 00bf349

Browse files
committed
Body.enable only exists in Arcade physics, so move conditions concerning this into arcarde
1 parent a0a7c02 commit 00bf349

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

src/gameobjects/Sprite.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
155155

156156
/**
157157
* A small internal cache:
158-
*
158+
*
159159
* 0 = previous position.x
160160
* 1 = previous position.y
161161
* 2 = previous rotation
@@ -209,7 +209,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
209209
this._cache[1] = this.world.y;
210210
this._cache[2] = this.rotation;
211211

212-
if (this.body && this.body.enable)
212+
if (this.body)
213213
{
214214
this.body.preUpdate();
215215
}
@@ -284,7 +284,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
284284

285285
this.animations.update();
286286

287-
if (this.body && this.body.enable)
287+
if (this.body)
288288
{
289289
this.body.preUpdate();
290290
}
@@ -323,7 +323,7 @@ Phaser.Sprite.prototype.postUpdate = function() {
323323
this.key.render();
324324
}
325325

326-
if (this.exists && this.body && this.body.enable)
326+
if (this.exists && this.body)
327327
{
328328
this.body.postUpdate();
329329
}
@@ -355,7 +355,7 @@ Phaser.Sprite.prototype.postUpdate = function() {
355355
Phaser.Sprite.prototype.loadTexture = function (key, frame) {
356356

357357
frame = frame || 0;
358-
358+
359359
this.key = key;
360360

361361
if (key instanceof Phaser.RenderTexture)
@@ -531,10 +531,10 @@ Phaser.Sprite.prototype.updateCrop = function() {
531531
/**
532532
* Crop allows you to crop the texture used to display this Sprite.
533533
* This modifies the core Sprite texture frame, so the Sprite width/height properties will adjust accordingly.
534-
*
534+
*
535535
* Cropping takes place from the top-left of the Sprite and can be modified in real-time by either providing an updated rectangle object to Sprite.crop,
536536
* or by modifying Sprite.cropRect (or a reference to it) and then calling Sprite.updateCrop.
537-
*
537+
*
538538
* The rectangle object given to this method can be either a Phaser.Rectangle or any object so long as it has public x, y, width and height properties.
539539
* A reference to the rectangle is stored in Sprite.cropRect unless the `copy` parameter is `true` in which case the values are duplicated to a local object.
540540
*
@@ -809,7 +809,7 @@ Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete)
809809
* Checks to see if the bounds of this Sprite overlaps with the bounds of the given Display Object, which can be a Sprite, Image, TileSprite or anything that extends those such as a Button.
810810
* This check ignores the Sprites hitArea property and runs a Sprite.getBounds comparison on both objects to determine the result.
811811
* Therefore it's relatively expensive to use in large quantities (i.e. with lots of Sprites at a high frequency), but should be fine for low-volume testing where physics isn't required.
812-
*
812+
*
813813
* @method Phaser.Sprite#overlap
814814
* @memberof Phaser.Sprite
815815
* @param {Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Button|PIXI.DisplayObject} displayObject - The display object to check against.

src/gameobjects/TileSprite.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Phaser.TileSprite.prototype.preUpdate = function() {
173173
this._cache[1] = this.world.y;
174174
this._cache[2] = this.rotation;
175175

176-
if (this.body && this.body.enable)
176+
if (this.body)
177177
{
178178
this.body.preUpdate();
179179
}
@@ -241,7 +241,7 @@ Phaser.TileSprite.prototype.preUpdate = function() {
241241
this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;
242242
}
243243

244-
if (this.body && this.body.enable)
244+
if (this.body)
245245
{
246246
this.body.preUpdate();
247247
}
@@ -274,7 +274,7 @@ Phaser.TileSprite.prototype.update = function() {
274274
*/
275275
Phaser.TileSprite.prototype.postUpdate = function() {
276276

277-
if (this.exists && this.body && this.body.enable)
277+
if (this.exists && this.body)
278278
{
279279
this.body.postUpdate();
280280
}
@@ -333,7 +333,7 @@ Phaser.TileSprite.prototype.stopScroll = function() {
333333
Phaser.TileSprite.prototype.loadTexture = function (key, frame) {
334334

335335
frame = frame || 0;
336-
336+
337337
this.key = key;
338338

339339
if (key instanceof Phaser.RenderTexture)
@@ -496,7 +496,7 @@ Phaser.TileSprite.prototype.play = function (name, frameRate, loop, killOnComple
496496
* Resets the TileSprite. This places the TileSprite at the given x/y world coordinates, resets the tilePosition and then
497497
* sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state.
498498
* If the TileSprite has a physics body that too is reset.
499-
*
499+
*
500500
* @method Phaser.TileSprite#reset
501501
* @memberof Phaser.TileSprite
502502
* @param {number} x - The x coordinate (in world space) to position the Sprite at.
@@ -525,7 +525,7 @@ Phaser.TileSprite.prototype.reset = function(x, y) {
525525
this._cache[4] = 1;
526526

527527
return this;
528-
528+
529529
};
530530

531531
/**

src/physics/arcade/Body.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ Phaser.Physics.Arcade.Body.prototype = {
365365
*/
366366
preUpdate: function () {
367367

368+
if (!this.enable)
369+
{
370+
return;
371+
}
372+
368373
this.phase = 1;
369374

370375
// Store and reset collision flags
@@ -440,6 +445,11 @@ Phaser.Physics.Arcade.Body.prototype = {
440445
*/
441446
postUpdate: function () {
442447

448+
if (!this.enable)
449+
{
450+
return;
451+
}
452+
443453
// Only allow postUpdate to be called once per frame
444454
if (this.phase === 2)
445455
{
@@ -612,7 +622,7 @@ Phaser.Physics.Arcade.Body.prototype = {
612622

613623
this._sx = this.sprite.scale.x;
614624
this._sy = this.sprite.scale.y;
615-
625+
616626
this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
617627

618628
},

0 commit comments

Comments
 (0)