diff --git a/README.md b/README.md index b73192ff..97f876ef 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ Updates: * Added hostname: '*' to the grunt-connect in Gruntfile.js (fixes #426) * Device, Canvas and GamePad classes all updated for better CocoonJS support (thanks Videlais) * BitmapData.alphaMask will draw the given image onto a BitmapData using an image as an alpha mask. +* The new GameObjectCreator (which you access via game.make or State.make) lets you easily create an object but NOT add it to the display list. Bug Fixes: diff --git a/src/physics/Body.js b/src/physics/Body.js index 218e90e0..8c351911 100644 --- a/src/physics/Body.js +++ b/src/physics/Body.js @@ -49,14 +49,14 @@ Phaser.Physics.Body = function (game, sprite, x, y, mass) { this.data.parent = this; /** - * @property {Phaser.PointProxy} velocity - The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down. + * @property {Phaser.InversePointProxy} velocity - The velocity of the body. Set velocity.x to a negative value to move to the left, position to the right. velocity.y negative values move up, positive move down. */ - this.velocity = new Phaser.Physics.PointProxy(this.data.velocity); + this.velocity = new Phaser.Physics.InversePointProxy(this.game, this.data.velocity); /** - * @property {Phaser.PointProxy} force - The force applied to the body. + * @property {Phaser.InversePointProxy} force - The force applied to the body. */ - this.force = new Phaser.Physics.PointProxy(this.data.force); + this.force = new Phaser.Physics.InversePointProxy(this.game, this.data.force); /** * @property {Phaser.Point} gravity - A locally applied gravity force to the Body. Applied directly before the world step. NOTE: Not currently implemented. diff --git a/src/physics/InversePointProxy.js b/src/physics/InversePointProxy.js index db936c9b..c00d9af7 100644 --- a/src/physics/InversePointProxy.js +++ b/src/physics/InversePointProxy.js @@ -10,10 +10,12 @@ * @class Phaser.Physics.InversePointProxy * @classdesc InversePointProxy * @constructor +* @param {Phaser.Game} game - A reference to the Phaser.Game instance. * @param {any} destination - The object to bind to. */ -Phaser.Physics.InversePointProxy = function (destination) { +Phaser.Physics.InversePointProxy = function (game, destination) { + this.game = game; this.destination = destination; }; @@ -34,7 +36,7 @@ Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "x", { set: function (value) { - this.destination[0] = -value; + this.destination[0] = this.game.math.px2p(-value); } @@ -54,7 +56,7 @@ Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "y", { set: function (value) { - this.destination[1] = -value; + this.destination[1] = this.game.math.px2p(-value); } diff --git a/src/physics/PointProxy.js b/src/physics/PointProxy.js index 57b43083..409ef782 100644 --- a/src/physics/PointProxy.js +++ b/src/physics/PointProxy.js @@ -10,10 +10,12 @@ * @class Phaser.Physics.PointProxy * @classdesc PointProxy * @constructor +* @param {Phaser.Game} game - A reference to the Phaser.Game instance. * @param {any} destination - The object to bind to. */ -Phaser.Physics.PointProxy = function (destination) { +Phaser.Physics.PointProxy = function (game, destination) { + this.game = game; this.destination = destination; }; @@ -34,7 +36,7 @@ Object.defineProperty(Phaser.Physics.PointProxy.prototype, "x", { set: function (value) { - this.destination[0] = value; + this.destination[0] = this.game.math.px2p(value); } @@ -54,7 +56,7 @@ Object.defineProperty(Phaser.Physics.PointProxy.prototype, "y", { set: function (value) { - this.destination[1] = value; + this.destination[1] = this.game.math.px2p(value); } diff --git a/src/utils/Debug.js b/src/utils/Debug.js index 2dedd032..a7a64b35 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -350,6 +350,21 @@ Phaser.Utils.Debug.prototype = { }, + /** + * Renders the Sprites bounds. Note: This is really expensive as it has to calculate the bounds every time you call it! + * @method Phaser.Utils.Debug#renderSpriteBounds + * @param {Phaser.Sprite} sprite - Description. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + * @param {boolean} [filled=true] - Render the rectangle as a fillRect (default, true) or a strokeRect (false) + */ + renderSpriteBounds: function (sprite, color, filled) { + + var bounds = sprite.getBounds(); + + this.renderRectangle(bounds, color, filled); + + }, + /** * Render debug infos (including name, bounds info, position and some other properties) about the Sprite. * @method Phaser.Utils.Debug#renderSpriteInfo