Velocity integration tidied up. Now moving to sync Body with Sprite center point.

This commit is contained in:
photonstorm
2014-01-28 01:29:35 +00:00
parent fbe508ab1b
commit 90c09374af
10 changed files with 291 additions and 316 deletions
+15 -7
View File
@@ -29,11 +29,6 @@ Phaser.Physics.Arcade = function (game) {
*/
this.gravity = new Phaser.Point();
/**
* @property {Phaser.Rectangle} bounds - The bounds inside of which the physics world exists. Defaults to match the world bounds.
*/
// this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height);
/**
* @property {Phaser.QuadTree} quadTree - The world QuadTree.
*/
@@ -91,6 +86,12 @@ Phaser.Physics.Arcade = function (game) {
*/
this._dy = 0;
/**
* @property {Phaser.Point} _p - Internal cache var.
* @private
*/
this._p = new Phaser.Point(0, 0);
/**
* @property {number} _gravityX - Internal cache var.
* @private
@@ -123,6 +124,12 @@ Phaser.Physics.Arcade.RECT = 0;
*/
Phaser.Physics.Arcade.CIRCLE = 1;
/**
* @constant
* @type {number}
*/
Phaser.Physics.Arcade.POLYGON = 2;
Phaser.Physics.Arcade.prototype = {
/**
@@ -194,8 +201,9 @@ Phaser.Physics.Arcade.prototype = {
// pos = pos + dt*(vel + temp/2)
// vel = vel + temp
body.motionVelocity.x = (body.acceleration.x + this._gravityX) * this.game.time.physicsElapsed;
body.motionVelocity.y = (body.acceleration.y + this._gravityY) * this.game.time.physicsElapsed;
this._p.setTo((body.acceleration.x + this._gravityX) * this.game.time.physicsElapsed, (body.acceleration.y + this._gravityY) * this.game.time.physicsElapsed);
return this._p;
},