Added Debug.renderSpriteBounds() back and wrapped Body.velocity and force in px2p calls.

This commit is contained in:
photonstorm
2014-02-21 15:34:15 +00:00
parent d7ababa398
commit 7ee0c20bb3
5 changed files with 30 additions and 10 deletions
+1
View File
@@ -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:
+4 -4
View File
@@ -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.
+5 -3
View File
@@ -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);
}
+5 -3
View File
@@ -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);
}
+15
View File
@@ -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