More tilemap tweaks.

This commit is contained in:
photonstorm
2013-10-14 19:37:52 +01:00
parent 6147e07a5f
commit dd695e066f
7 changed files with 1203 additions and 678 deletions
+15 -10
View File
@@ -65,6 +65,9 @@ Phaser.Physics.Arcade.Body = function (sprite) {
this.overlapX = 0;
this.overlapY = 0;
this.hullX = new Phaser.Rectangle();
this.hullY = new Phaser.Rectangle();
// If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true
this.embedded = false;
@@ -105,8 +108,6 @@ Phaser.Physics.Arcade.Body.prototype = {
this.embedded = false;
// this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
// this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preRotation = this.sprite.angle;
@@ -123,6 +124,8 @@ Phaser.Physics.Arcade.Body.prototype = {
{
this.checkWorldBounds();
}
this.updateHulls();
}
if (this.skipQuadTree == false && this.allowCollision.none == false && this.sprite.visible && this.sprite.alive)
@@ -174,6 +177,13 @@ Phaser.Physics.Arcade.Body.prototype = {
},
updateHulls: function () {
this.hullX.setTo(this.x, this.preY, this.width, this.height);
this.hullY.setTo(this.preX, this.y, this.width, this.height);
},
checkWorldBounds: function () {
if (this.x < this.game.world.bounds.x)
@@ -223,21 +233,16 @@ Phaser.Physics.Arcade.Body.prototype = {
this.angularVelocity = 0;
this.angularAcceleration = 0;
// this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
// this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preRotation = this.sprite.angle;
// this.x = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
// this.y = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.x = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.y = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.rotation = this.sprite.angle;
this.x = this.preX;
this.y = this.preY;
this.rotation = this.preRotation;
},
// Basically Math.abs
deltaAbsX: function () {
return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX());
},