Added Game Update loop step debugging - has proved utterly invaluable! Resolved camera jitter issues, gravity / downward force on tile/boundary issues and most tilemap collision issues.

This commit is contained in:
photonstorm
2014-01-31 02:06:45 +00:00
parent 651858372c
commit 6e4e99f436
11 changed files with 369 additions and 334 deletions
+2
View File
@@ -131,6 +131,8 @@ Phaser.Tile = function (layer, index, x, y, width, height) {
*/
this.callbackContext = this;
this.debug = false;
};
Phaser.Tile.prototype = {
+20 -8
View File
@@ -482,12 +482,16 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
height = this.layer.heightInPixels;
}
// console.log('getTiles', x, y, width, height, collides);
// Convert the pixel values into tile coordinates
this._tx = this.game.math.snapToFloor(x, this._cw) / this._cw;
this._ty = this.game.math.snapToFloor(y, this._ch) / this._ch;
this._tw = (this.game.math.snapToCeil(width, this._cw) + this._cw) / this._cw;
this._th = (this.game.math.snapToCeil(height, this._ch) + this._ch) / this._ch;
// console.log('getTiles snapped', this._tx, this._ty, this._tw, this._th);
// This should apply the layer x/y here
this._results.length = 0;
@@ -526,6 +530,8 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
}
}
// console.log('getTiles results', this._results);
return this._results;
}
@@ -708,15 +714,15 @@ Phaser.TilemapLayer.prototype.updateMax = function () {
*/
Phaser.TilemapLayer.prototype.render = function () {
if (this.layer.dirty)
{
this.dirty = true;
}
// if (this.layer.dirty)
// {
// this.dirty = true;
// }
if (!this.dirty || !this.visible)
{
return;
}
// if (!this.dirty || !this.visible)
// {
// return;
// }
this._prevX = this._dx;
this._prevY = this._dy;
@@ -790,6 +796,12 @@ Phaser.TilemapLayer.prototype.render = function () {
this.map.tileHeight
);
}
if (tile.debug)
{
this.context.fillStyle = 'rgba(0,255,0,0.5)';
this.context.fillRect(Math.floor(this._tx), Math.floor(this._ty), this.map.tileWidth, this.map.tileHeight);
}
}
else
{