mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
Recalculate faces: make this reset faces on non-colliding tiles
This handles edge cases where things like copy can make a tile become non-colliding w/o reseting faces
This commit is contained in:
parent
ef942fb204
commit
01f34e18b7
3 changed files with 33 additions and 9 deletions
|
@ -286,6 +286,21 @@ var Tile = new Class({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset faces.
|
||||||
|
*
|
||||||
|
* @returns {this}
|
||||||
|
*/
|
||||||
|
resetFaces: function ()
|
||||||
|
{
|
||||||
|
this.faceTop = false;
|
||||||
|
this.faceBottom = false;
|
||||||
|
this.faceLeft = false;
|
||||||
|
this.faceRight = false;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the collision flags for each side of this tile and updates the interesting faces list.
|
* Sets the collision flags for each side of this tile and updates the interesting faces list.
|
||||||
*
|
*
|
||||||
|
|
|
@ -25,7 +25,9 @@ var CalculateFacesWithin = function (tileX, tileY, width, height, layer)
|
||||||
{
|
{
|
||||||
var tile = tiles[i];
|
var tile = tiles[i];
|
||||||
|
|
||||||
if (tile && tile.collides)
|
if (tile)
|
||||||
|
{
|
||||||
|
if (tile.collides)
|
||||||
{
|
{
|
||||||
above = GetTileAt(tile.x, tile.y - 1, true, layer);
|
above = GetTileAt(tile.x, tile.y - 1, true, layer);
|
||||||
below = GetTileAt(tile.x, tile.y + 1, true, layer);
|
below = GetTileAt(tile.x, tile.y + 1, true, layer);
|
||||||
|
@ -37,6 +39,11 @@ var CalculateFacesWithin = function (tileX, tileY, width, height, layer)
|
||||||
tile.faceLeft = (left && left.collides) ? false : true;
|
tile.faceLeft = (left && left.collides) ? false : true;
|
||||||
tile.faceRight = (right && right.collides) ? false : true;
|
tile.faceRight = (right && right.collides) ? false : true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tile.resetFaces();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ var RecalculateFacesAt = function (tileX, tileY, layer)
|
||||||
right.faceLeft = !tileCollides;
|
right.faceLeft = !tileCollides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tile && !tile.collides) { tile.resetFaces(); }
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue