From b07ce892369e842a247963acd0760d91e448509e Mon Sep 17 00:00:00 2001 From: photonstorm Date: Mon, 23 Mar 2015 15:05:39 +0000 Subject: [PATCH] sourceWidth / Height now only set from the texture if the object has a texture. --- src/physics/arcade/Body.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index c3275b5ad..762692e7e 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -71,18 +71,6 @@ Phaser.Physics.Arcade.Body = function (sprite) { */ this.preRotation = sprite.rotation; - /** - * @property {number} sourceWidth - The un-scaled original size. - * @readonly - */ - this.sourceWidth = sprite.texture.frame.width; - - /** - * @property {number} sourceHeight - The un-scaled original size. - * @readonly - */ - this.sourceHeight = sprite.texture.frame.height; - /** * @property {number} width - The calculated width of the physics body. * @readonly @@ -95,6 +83,24 @@ Phaser.Physics.Arcade.Body = function (sprite) { */ this.height = sprite.height; + /** + * @property {number} sourceWidth - The un-scaled original size. + * @readonly + */ + this.sourceWidth = sprite.width; + + /** + * @property {number} sourceHeight - The un-scaled original size. + * @readonly + */ + this.sourceHeight = sprite.height; + + if (sprite.texture) + { + this.sourceWidth = sprite.texture.frame.width; + this.sourceHeight = sprite.texture.frame.height; + } + /** * @property {number} halfWidth - The calculated width / 2 of the physics body. * @readonly @@ -650,9 +656,7 @@ Phaser.Physics.Arcade.Body.prototype = { * @return {boolean} True if the given coordinates are inside this Body, otherwise false. */ hitTest: function (x, y) { - return Phaser.Rectangle.contains(this, x, y); - }, /**