@@ -20,10 +20,11 @@ var TileIntersectsBody = require('./TileIntersectsBody');
2020 * @param {Phaser.Geom.Rectangle } tileWorldRect - A rectangle-like object defining the dimensions of the tile.
2121 * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer) } tilemapLayer - The tilemapLayer to collide against.
2222 * @param {number } tileBias - The tile bias value. Populated by the `World.TILE_BIAS` constant.
23+ * @param {boolean } isLayer - Is this check coming from a TilemapLayer or an array of tiles?
2324 *
2425 * @return {boolean } `true` if the body was separated, otherwise `false`.
2526 */
26- var SeparateTile = function ( i , body , tile , tileWorldRect , tilemapLayer , tileBias )
27+ var SeparateTile = function ( i , body , tile , tileWorldRect , tilemapLayer , tileBias , isLayer )
2728{
2829 var tileLeft = tileWorldRect . left ;
2930 var tileTop = tileWorldRect . top ;
@@ -32,6 +33,12 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
3233 var faceHorizontal = tile . faceLeft || tile . faceRight ;
3334 var faceVertical = tile . faceTop || tile . faceBottom ;
3435
36+ if ( ! isLayer )
37+ {
38+ faceHorizontal = true ;
39+ faceVertical = true ;
40+ }
41+
3542 // We don't need to go any further if this tile doesn't actually have any colliding faces. This
3643 // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't
3744 // needed for separation.
@@ -68,7 +75,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
6875 {
6976 if ( faceHorizontal )
7077 {
71- ox = TileCheckX ( body , tile , tileLeft , tileRight , tileBias ) ;
78+ ox = TileCheckX ( body , tile , tileLeft , tileRight , tileBias , isLayer ) ;
7279
7380 // That's horizontal done, check if we still intersects? If not then we can return now
7481 if ( ox !== 0 && ! TileIntersectsBody ( tileWorldRect , body ) )
@@ -79,14 +86,14 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
7986
8087 if ( faceVertical )
8188 {
82- oy = TileCheckY ( body , tile , tileTop , tileBottom , tileBias ) ;
89+ oy = TileCheckY ( body , tile , tileTop , tileBottom , tileBias , isLayer ) ;
8390 }
8491 }
8592 else
8693 {
8794 if ( faceVertical )
8895 {
89- oy = TileCheckY ( body , tile , tileTop , tileBottom , tileBias ) ;
96+ oy = TileCheckY ( body , tile , tileTop , tileBottom , tileBias , isLayer ) ;
9097
9198 // That's vertical done, check if we still intersects? If not then we can return now
9299 if ( oy !== 0 && ! TileIntersectsBody ( tileWorldRect , body ) )
@@ -97,7 +104,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
97104
98105 if ( faceHorizontal )
99106 {
100- ox = TileCheckX ( body , tile , tileLeft , tileRight , tileBias ) ;
107+ ox = TileCheckX ( body , tile , tileLeft , tileRight , tileBias , isLayer ) ;
101108 }
102109 }
103110
0 commit comments