77*
88* Phaser - http://www.phaser.io
99*
10- * v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 02:05:04
10+ * v2.0.1 "Aes Sedai" - Built: Wed Mar 19 2014 03:53:38
1111*
1212* By Richard Davey http://www.photonstorm.com @photonstorm
1313*
@@ -33736,6 +33736,9 @@ Phaser.Utils.Debug.prototype = {
3373633736
3373733737 var bounds = sprite.getBounds();
3373833738
33739+ bounds.x += this.game.camera.x;
33740+ bounds.y += this.game.camera.y;
33741+
3373933742 this.rectangle(bounds, color, filled);
3374033743
3374133744 },
@@ -34632,6 +34635,11 @@ Phaser.Physics.prototype = {
3463234635 */
3463334636 setBoundsToWorld: function () {
3463434637
34638+ if (this.arcade)
34639+ {
34640+ this.arcade.setBoundsToWorld();
34641+ }
34642+
3463534643 if (this.ninja)
3463634644 {
3463734645 this.ninja.setBoundsToWorld();
@@ -34739,18 +34747,6 @@ Phaser.Physics.Arcade = function (game) {
3473934747
3474034748 // Avoid gc spikes by caching these values for re-use
3474134749
34742- /**
34743- * @property {Phaser.Rectangle} _bounds1 - Internal cache var.
34744- * @private
34745- */
34746- this._bounds1 = new Phaser.Rectangle();
34747-
34748- /**
34749- * @property {Phaser.Rectangle} _bounds2 - Internal cache var.
34750- * @private
34751- */
34752- this._bounds2 = new Phaser.Rectangle();
34753-
3475434750 /**
3475534751 * @property {number} _overlap - Internal cache var.
3475634752 * @private
@@ -34799,12 +34795,6 @@ Phaser.Physics.Arcade = function (game) {
3479934795 */
3480034796 this._mapData = [];
3480134797
34802- /**
34803- * @property {number} _mapTiles - Internal cache var.
34804- * @private
34805- */
34806- this._mapTiles = 0;
34807-
3480834798 /**
3480934799 * @property {boolean} _result - Internal cache var.
3481034800 * @private
@@ -34835,19 +34825,38 @@ Phaser.Physics.Arcade = function (game) {
3483534825 */
3483634826 this._dy = 0;
3483734827
34838- /**
34839- * @property {number} _intersection - Internal cache var.
34840- * @private
34841- */
34842- // this._intersection = [0,0,0,0];
34843- this._intersection = new Phaser.Rectangle();
34844-
3484534828};
3484634829
3484734830Phaser.Physics.Arcade.prototype.constructor = Phaser.Physics.Arcade;
3484834831
3484934832Phaser.Physics.Arcade.prototype = {
3485034833
34834+ /**
34835+ * Updates the size of this physics world.
34836+ *
34837+ * @method Phaser.Physics.Arcade#setBounds
34838+ * @param {number} x - Top left most corner of the world.
34839+ * @param {number} y - Top left most corner of the world.
34840+ * @param {number} width - New width of the world. Can never be smaller than the Game.width.
34841+ * @param {number} height - New height of the world. Can never be smaller than the Game.height.
34842+ */
34843+ setBounds: function (x, y, width, height) {
34844+
34845+ this.bounds.setTo(x, y, width, height);
34846+
34847+ },
34848+
34849+ /**
34850+ * Updates the size of this physics world to match the size of the game world.
34851+ *
34852+ * @method Phaser.Physics.Arcade#setBoundsToWorld
34853+ */
34854+ setBoundsToWorld: function () {
34855+
34856+ this.bounds.setTo(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height);
34857+
34858+ },
34859+
3485134860 /**
3485234861 * This will create an Arcade Physics body on the given game object or array of game objects.
3485334862 * A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.
@@ -35901,7 +35910,6 @@ Phaser.Physics.Arcade.prototype = {
3590135910 }
3590235911
3590335912 body.position.x -= x;
35904- body.preX -= x;
3590535913
3590635914 if (body.bounce.x === 0)
3590735915 {
@@ -35933,7 +35941,6 @@ Phaser.Physics.Arcade.prototype = {
3593335941 }
3593435942
3593535943 body.position.y -= y;
35936- body.preY -= y;
3593735944
3593835945 if (body.bounce.y === 0)
3593935946 {
@@ -36349,16 +36356,6 @@ Phaser.Physics.Arcade.Body = function (sprite) {
3634936356 */
3635036357 this.offset = new Phaser.Point();
3635136358
36352- if (sprite.anchor.x !== 0)
36353- {
36354- this.offset.x = (sprite.anchor.x * sprite.width);
36355- }
36356-
36357- if (sprite.anchor.y !== 0)
36358- {
36359- this.offset.y = (sprite.anchor.y * sprite.height);
36360- }
36361-
3636236359 /**
3636336360 * @property {Phaser.Point} position - The position of the physics body.
3636436361 * @readonly
@@ -36643,7 +36640,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3664336640 this.halfHeight = Math.floor(this.height / 2);
3664436641 this._sx = scaleX;
3664536642 this._sy = scaleY;
36646- this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
36643+ this.center.setTo(this.position. x + this.halfWidth, this.position .y + this.halfHeight);
3664736644 }
3664836645
3664936646 },
@@ -36669,13 +36666,21 @@ Phaser.Physics.Arcade.Body.prototype = {
3666936666 this.touching.left = false;
3667036667 this.touching.right = false;
3667136668
36672- this.embedded = false;
36673-
3667436669 this.blocked.up = false;
3667536670 this.blocked.down = false;
3667636671 this.blocked.left = false;
3667736672 this.blocked.right = false;
3667836673
36674+ this.embedded = false;
36675+
36676+ this.position.x = (this.sprite.world.x - (this.sprite.anchor.x * this.width)) + this.offset.x;
36677+ this.position.y = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y;
36678+ this.rotation = this.sprite.angle;
36679+
36680+ this.prev.x = this.position.x;
36681+ this.prev.y = this.position.y;
36682+ this.preRotation = this.rotation;
36683+
3667936684 if (this.moves)
3668036685 {
3668136686 this.game.physics.arcade.updateMotion(this);
@@ -36699,12 +36704,6 @@ Phaser.Physics.Arcade.Body.prototype = {
3669936704 this.checkWorldBounds();
3670036705 }
3670136706 }
36702- else
36703- {
36704- // If the body doesn't move (i.e. is in a moving Group) then we need its position
36705- this.position.x = (this.sprite.world.x - (this.sprite.anchor.x * this.width)) + this.offset.x;
36706- this.position.y = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y;
36707- }
3670836707
3670936708 },
3671036709
@@ -36736,20 +36735,17 @@ Phaser.Physics.Arcade.Body.prototype = {
3673636735
3673736736 if (this.moves)
3673836737 {
36739- this.sprite.x = this.position.x + this.offset.x ;
36740- this.sprite.y = this.position.y + this.offset.y ;
36738+ this.sprite.x + = this.deltaX() ;
36739+ this.sprite.y + = this.deltaY() ;
3674136740 }
3674236741
36743- this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
36742+ this.center.setTo(this.position. x + this.halfWidth, this.position .y + this.halfHeight);
3674436743
3674536744 if (this.allowRotation)
3674636745 {
3674736746 this.sprite.angle += this.deltaZ();
3674836747 }
3674936748
36750- this.prev.set(this.position.x, this.position.y);
36751- this.preRotation = this.rotation;
36752-
3675336749 },
3675436750
3675536751 /**
@@ -36771,28 +36767,28 @@ Phaser.Physics.Arcade.Body.prototype = {
3677136767 */
3677236768 checkWorldBounds: function () {
3677336769
36774- if (this.x < this.game.world .bounds.x)
36770+ if (this.position. x < this.game.physics.arcade .bounds.x)
3677536771 {
36776- this.x = this.game.world .bounds.x;
36772+ this.position. x = this.game.physics.arcade .bounds.x;
3677736773 this.velocity.x *= -this.bounce.x;
3677836774 this.blocked.left = true;
3677936775 }
36780- else if (this.right > this.game.world .bounds.right)
36776+ else if (this.right > this.game.physics.arcade .bounds.right)
3678136777 {
36782- this.x = this.game.world .bounds.right - this.width;
36778+ this.position. x = this.game.physics.arcade .bounds.right - this.width;
3678336779 this.velocity.x *= -this.bounce.x;
3678436780 this.blocked.right = true;
3678536781 }
3678636782
36787- if (this.y < this.game.world .bounds.y)
36783+ if (this.position. y < this.game.physics.arcade .bounds.y)
3678836784 {
36789- this.y = this.game.world .bounds.y;
36785+ this.position. y = this.game.physics.arcade .bounds.y;
3679036786 this.velocity.y *= -this.bounce.y;
3679136787 this.blocked.up = true;
3679236788 }
36793- else if (this.bottom > this.game.world .bounds.bottom)
36789+ else if (this.bottom > this.game.physics.arcade .bounds.bottom)
3679436790 {
36795- this.y = this.game.world .bounds.bottom - this.height;
36791+ this.position. y = this.game.physics.arcade .bounds.bottom - this.height;
3679636792 this.velocity.y *= -this.bounce.y;
3679736793 this.blocked.down = true;
3679836794 }
@@ -36823,7 +36819,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3682336819 this.halfHeight = Math.floor(this.height / 2);
3682436820 this.offset.setTo(offsetX, offsetY);
3682536821
36826- this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
36822+ this.center.setTo(this.position. x + this.halfWidth, this.position .y + this.halfHeight);
3682736823
3682836824 },
3682936825
@@ -36847,7 +36843,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3684736843 this.rotation = this.sprite.rotation;
3684836844 this.preRotation = this.rotation;
3684936845
36850- this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
36846+ this.center.setTo(this.position. x + this.halfWidth, this.position .y + this.halfHeight);
3685136847
3685236848 },
3685336849
@@ -37022,7 +37018,7 @@ Phaser.Physics.Arcade.Body.renderBodyInfo = function (debug, body) {
3702237018
3702337019 debug.line('x: ' + body.x.toFixed(2), 'y: ' + body.y.toFixed(2), 'width: ' + body.width, 'height: ' + body.height);
3702437020 // debug.line('velocity x: ' + body.velocity.x.toFixed(2), 'y: ' + body.velocity.y.toFixed(2), 'deltaX: ' + body.deltaX().toFixed(2), 'deltaY: ' + body.deltaY().toFixed(2));
37025- debug.line('velocity x: ' + body.velocity.x.toFixed(2), 'y: ' + body.velocity.y.toFixed(2));
37021+ debug.line('velocity x: ' + body.velocity.x.toFixed(2), 'y: ' + body.velocity.y.toFixed(2), 'new velocity x: ' + body.newVelocity.x.toFixed(2), 'y: ' + body.newVelocity.y.toFixed(2) );
3702637022 debug.line('acceleration x: ' + body.acceleration.x.toFixed(2), 'y: ' + body.acceleration.y.toFixed(2), 'speed: ' + body.speed.toFixed(2), 'angle: ' + body.angle.toFixed(2));
3702737023 debug.line('gravity x: ' + body.gravity.x, 'y: ' + body.gravity.y, 'bounce x: ' + body.bounce.x.toFixed(2), 'y: ' + body.bounce.y.toFixed(2));
3702837024 debug.line('touching left: ' + body.touching.left, 'right: ' + body.touching.right, 'up: ' + body.touching.up, 'down: ' + body.touching.down);
0 commit comments