Removed debug info and tidying up ready for release.

This commit is contained in:
photonstorm
2014-02-05 16:54:58 +00:00
parent 1af86771ba
commit 846e9c5061
46 changed files with 1644 additions and 16323 deletions
+1 -38
View File
@@ -234,11 +234,6 @@ Phaser.Physics.Arcade.prototype = {
rebounded = true;
}
if (body.sprite.debug)
{
console.log('checkBounds finished', rebounded, body.blocked);
}
return rebounded;
},
@@ -850,10 +845,6 @@ Phaser.Physics.Arcade.prototype = {
return this._intersection;
}
// console.log('____ tileIntersects');
// console.log('body: ', body.left, body.top, body.right, body.bottom);
// console.log('tile: ', tile.x, tile.y, tile.right, tile.bottom);
if (!(body.right < tile.x || body.bottom < tile.y || body.left > tile.right || body.top > tile.bottom))
{
this._intersection[0] = Math.max(body.left, tile.x); // x
@@ -866,6 +857,7 @@ Phaser.Physics.Arcade.prototype = {
}
this._intersection[4] = 0;
return this._intersection;
},
@@ -879,8 +871,6 @@ Phaser.Physics.Arcade.prototype = {
*/
separateTiles: function (body, tiles) {
// console.log('!!! separateTiles', tiles);
var tile;
var result = false;
@@ -912,15 +902,9 @@ Phaser.Physics.Arcade.prototype = {
// If the intersection area is either entirely null, or has a width/height of zero, we bail out now
if (this._intersection[4] === 0 || this._intersection[2] === 0 || this._intersection[3] === 0)
{
// console.log('Tile does not intersect body');
return false;
}
// console.log('*** separateTile', tile);
// console.log('intersection', this._intersection);
// tile.tile.debug = true;
// They overlap. Any custom callbacks?
if (tile.tile.callback || tile.layer.callbacks[tile.tile.index])
{
@@ -947,8 +931,6 @@ Phaser.Physics.Arcade.prototype = {
// LEFT
body.overlapX = body.left - tile.right;
// console.log('ST left', body.overlapX, body.deltaX(), 'bt', body.left, tile.right);
if (body.overlapX < 0)
{
process = true;
@@ -963,8 +945,6 @@ Phaser.Physics.Arcade.prototype = {
// RIGHT
body.overlapX = body.right - tile.x;
// console.log('ST right', body.overlapX, body.deltaX(), 'bt', body.right, tile.x);
if (body.overlapX > 0)
{
process = true;
@@ -980,8 +960,6 @@ Phaser.Physics.Arcade.prototype = {
// UP
body.overlapY = body.top - tile.bottom;
// console.log('ST up', body.overlapY, body.deltaY(), 'bt', body.top, tile.bottom);
if (body.overlapY < 0)
{
process = true;
@@ -996,8 +974,6 @@ Phaser.Physics.Arcade.prototype = {
// DOWN
body.overlapY = body.bottom - tile.y;
// console.log('ST down', body.overlapY, body.deltaY(), 'bt', body.bottom, tile.y);
if (body.overlapY > 0)
{
process = true;
@@ -1042,8 +1018,6 @@ Phaser.Physics.Arcade.prototype = {
*/
processTileSeparation: function (body) {
// console.log('PRE processTileSeparation xy', body.x, body.y, 'left', body.left, 'right', body.right, 'up', body.up, 'down', body.down);
if (body.overlapX < 0)
{
body.x -= body.overlapX;
@@ -1052,8 +1026,6 @@ Phaser.Physics.Arcade.prototype = {
body.blocked.x = Math.floor(body.x);
body.blocked.y = Math.floor(body.y);
body.blocked.left = true;
// body.touching.left = true;
// body.touching.none = false;
}
else if (body.overlapX > 0)
{
@@ -1063,8 +1035,6 @@ Phaser.Physics.Arcade.prototype = {
body.blocked.x = Math.floor(body.x);
body.blocked.y = Math.floor(body.y);
body.blocked.right = true;
// body.touching.right = true;
// body.touching.none = false;
}
if (body.overlapY < 0)
@@ -1075,9 +1045,6 @@ Phaser.Physics.Arcade.prototype = {
body.blocked.x = Math.floor(body.x);
body.blocked.y = Math.floor(body.y);
body.blocked.up = true;
// body.touching.up = true;
// body.touching.none = false;
}
else if (body.overlapY > 0)
{
@@ -1087,12 +1054,8 @@ Phaser.Physics.Arcade.prototype = {
body.blocked.x = Math.floor(body.x);
body.blocked.y = Math.floor(body.y);
body.blocked.down = true;
// body.touching.down = true;
// body.touching.none = false;
}
// console.log('POST processTileSeparation xy', body.x, body.y, 'left', body.left, 'right', body.right, 'up', body.up, 'down', body.down);
return true;
},
+10 -94
View File
@@ -393,20 +393,6 @@ Phaser.Physics.Arcade.Body.prototype = {
this.updateScale();
}
if (this.sprite.debug)
{
console.log('Body preUpdate x:', this.x, 'y:', this.y);
// console.log('Body preUpdate Sprite x:', this.sprite.x, 'y:', this.sprite.y);
// console.log('Body preUpdate Sprite world:', this.sprite.world.x, 'y:', this.sprite.world.y);
// console.log('Body preUpdate Sprite position:', this.sprite.position.x, 'y:', this.sprite.position.y);
// console.log('Body preUpdate Sprite localTransform:', this.sprite.localTransform[2], 'y:', this.sprite.localTransform[5]);
// console.log('Body preUpdate Sprite worldTransform:', this.sprite.worldTransform[2], 'y:', this.sprite.worldTransform[5]);
// console.log('Body preUpdate x:', this.x, 'y:', this.y, 'left:', this.left, 'right:', this.right, 'WAS', this.preX, this.preY);
console.log('Body preUpdate blocked:', this.blocked, this.blockFlags);
console.log('Body preUpdate velocity:', this.velocity.x, this.velocity.y);
// console.log('Body preUpdate rotation:', this.rotation, this.preRotation);
}
this.checkBlocked();
this.touching.none = true;
@@ -444,12 +430,6 @@ if (this.sprite.debug)
this.updateBounds();
}
if (this.sprite.debug)
{
console.log('Body preUpdate AFTER integration x:', this.x, 'y:', this.y, 'left:', this.left, 'right:', this.right);
console.log('Body preUpdate velocity:', this.velocity.x, this.velocity.y);
}
},
/**
@@ -462,14 +442,12 @@ if (this.sprite.debug)
if ((this.blocked.left || this.blocked.right) && (Math.floor(this.x) !== this.blocked.x || Math.floor(this.y) !== this.blocked.y))
{
// console.log('resetBlocked unlocked left + right', Math.floor(this.x), this.blocked.x);
this.blocked.left = false;
this.blocked.right = false;
}
if ((this.blocked.up || this.blocked.down) && (Math.floor(this.x) !== this.blocked.x || Math.floor(this.y) !== this.blocked.y))
{
// console.log('resetBlocked unlocked up + down', Math.floor(this.y), this.blocked.y, 'x', Math.floor(this.x), this.blocked.x);
this.blocked.up = false;
this.blocked.down = false;
}
@@ -547,12 +525,6 @@ if (this.sprite.debug)
*/
reboundCheck: function (x, y, rebound) {
if (this.sprite.debug)
{
console.log('reboundCheck start', this.velocity.x, this.velocity.y);
console.log('reBound blocked state', this.blocked);
}
if (x)
{
if (rebound && this.bounce.x !== 0 && (this.blocked.left || this.blocked.right || this.touching.left || this.touching.right))
@@ -562,11 +534,6 @@ if (this.sprite.debug)
{
this.velocity.x *= -this.bounce.x;
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
if (this.sprite.debug)
{
console.log('X rebound applied', this._vx, 'to', this.velocity.x);
}
}
}
@@ -577,16 +544,6 @@ if (this.sprite.debug)
if (((this.blocked.left || this.touching.left) && (gx < 0 || this.velocity.x < 0)) || ((this.blocked.right || this.touching.right) && (gx > 0 || this.velocity.x > 0)))
{
this.velocity.x = 0;
if (this.sprite.debug)
{
console.log('reboundCheck X zeroed');
}
}
if (this.sprite.debug)
{
console.log('reboundCheck X', this.velocity.x, 'gravity', gx);
}
}
}
@@ -600,13 +557,6 @@ if (this.sprite.debug)
{
this.velocity.y *= -this.bounce.y;
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
if (this.sprite.debug)
{
console.log('Y rebound applied', this._vy, 'to', this.velocity.y);
console.log('Y rebound check 1', !(this._vy <= 0 && this.velocity.y > 0));
console.log('Y rebound check 2', !(this._vy >= 0 && this.velocity.y < 0));
}
}
}
@@ -617,16 +567,6 @@ if (this.sprite.debug)
if (((this.blocked.up || this.touching.up) && (gy < 0 || this.velocity.y < 0)) || ((this.blocked.down || this.touching.down) && (gy > 0 || this.velocity.y > 0)))
{
this.velocity.y = 0;
if (this.sprite.debug)
{
console.log('reboundCheck Y zeroed');
}
}
if (this.sprite.debug)
{
console.log('reboundCheck Y', this.velocity.y, 'gravity', gy);
}
}
}
@@ -819,8 +759,16 @@ if (this.sprite.debug)
*/
processRebound: function (body) {
this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
// Don't rebound again if they've already rebounded in this frame
if (!(this._vx <= 0 && this.velocity.x > 0) && !(this._vx >= 0 && this.velocity.x < 0))
{
this.velocity.x = body.velocity.x - this.velocity.x * this.bounce.x;
}
if (!(this._vy <= 0 && this.velocity.y > 0) && !(this._vy >= 0 && this.velocity.y < 0))
{
this.velocity.y = body.velocity.y - this.velocity.y * this.bounce.y;
}
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
@@ -973,12 +921,10 @@ if (this.sprite.debug)
// Which is smaller? Left or Right?
if (this._distances[0] < this._distances[1] && (body.checkCollision.right || this.checkCollision.left))
{
// console.log(this.sprite.name, 'collided on the LEFT with', body.sprite.name, response);
hasSeparated = this.hitLeft(body, response);
}
else if (this._distances[1] < this._distances[0] && (body.checkCollision.left || this.checkCollision.right))
{
// console.log(this.sprite.name, 'collided on the RIGHT with', body.sprite.name, response);
hasSeparated = this.hitRight(body, response);
}
}
@@ -987,19 +933,16 @@ if (this.sprite.debug)
// Which is smaller? Top or Bottom?
if (this._distances[2] < this._distances[3] && (body.checkCollision.down || this.checkCollision.up))
{
// console.log(this.sprite.name, 'collided on the TOP with', body.sprite.name, response);
hasSeparated = this.hitTop(body, response);
}
else if (this._distances[3] < this._distances[2] && (body.checkCollision.up || this.checkCollision.down))
{
// console.log(this.sprite.name, 'collided on the BOTTOM with', body.sprite.name, response);
hasSeparated = this.hitBottom(body, response);
}
}
if (hasSeparated)
{
console.log('Body hasSeparated');
this.game.physics.checkBounds(this);
this.game.physics.checkBounds(body);
}
@@ -1200,11 +1143,6 @@ if (this.sprite.debug)
this._dx = this.game.time.physicsElapsed * (this.velocity.x + this._temp.x / 2);
this._dy = this.game.time.physicsElapsed * (this.velocity.y + this._temp.y / 2);
if (this.sprite.debug)
{
// console.log('integrateVelocity TEMP:', this._temp.x, this._temp.y);
}
// positive = RIGHT / DOWN
// negative = LEFT / UP
@@ -1212,34 +1150,12 @@ if (this.sprite.debug)
{
this.x += this._dx;
this.velocity.x += this._temp.x;
if (this.sprite.debug)
{
// console.log('integrateVelocity x added', this._dx, this.x);
}
}
else
{
if (this.sprite.debug)
{
// console.log('integrateVelocity x failed or zero, blocked left/right', this._dx);
}
}
if ((this._dy < 0 && !this.blocked.up && !this.touching.up) || (this._dy > 0 && !this.blocked.down && !this.touching.down))
{
this.y += this._dy;
this.velocity.y += this._temp.y;
if (this.sprite.debug)
{
// console.log('integrateVelocity y added', this._dy, this.y);
}
}
else
{
if (this.sprite.debug)
{
// console.log('integrateVelocity y failed or zero, blocked up/down', this._dy);
}
}
if (this.velocity.x > this.maxVelocity.x)