Skip to content

Commit 0d934c7

Browse files
committed
Every single Tilemap.Component function has now been made public. This means you can call the Component functions directly, should you need to, outside of the Tilemap system.
1 parent 09f11b8 commit 0d934c7

45 files changed

Lines changed: 113 additions & 83 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ The way in which Game Objects add themselves to the Scene Update List has change
300300
* The `Phaser.Scenes.GetScenePlugins` function has now been exposed on the Phaser namespace (thanks @samme)
301301
* The `Phaser.Structs.Events` namespace has now been exposed on the Phaser namespace (thanks @samme)
302302
* The `Phaser.Tilemaps.Parsers.Tiled` function has now been exposed on the Phaser namespace (thanks @samme)
303+
* Every single `Tilemap.Component` function has now been made public. This means you can call the Component functions directly, should you need to, outside of the Tilemap system.
303304

304305
### Bug Fixes
305306

src/tilemaps/components/CalculateFacesAt.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ var GetTileAt = require('./GetTileAt');
1212
* internally to optimize recalculating faces when only one tile has been changed.
1313
*
1414
* @function Phaser.Tilemaps.Components.CalculateFacesAt
15-
* @private
1615
* @since 3.0.0
17-
*
16+
*
1817
* @param {integer} tileX - The x coordinate.
1918
* @param {integer} tileY - The y coordinate.
2019
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
@@ -40,29 +39,48 @@ var CalculateFacesAt = function (tileX, tileY, layer)
4039
// Reset edges that are shared between tile and its neighbors
4140
if (above && above.collides)
4241
{
43-
if (tileCollides) { tile.faceTop = false; }
42+
if (tileCollides)
43+
{
44+
tile.faceTop = false;
45+
}
46+
4447
above.faceBottom = !tileCollides;
4548
}
4649

4750
if (below && below.collides)
4851
{
49-
if (tileCollides) { tile.faceBottom = false; }
52+
if (tileCollides)
53+
{
54+
tile.faceBottom = false;
55+
}
56+
5057
below.faceTop = !tileCollides;
5158
}
5259

5360
if (left && left.collides)
5461
{
55-
if (tileCollides) { tile.faceLeft = false; }
62+
if (tileCollides)
63+
{
64+
tile.faceLeft = false;
65+
}
66+
5667
left.faceRight = !tileCollides;
5768
}
5869

5970
if (right && right.collides)
6071
{
61-
if (tileCollides) { tile.faceRight = false; }
72+
if (tileCollides)
73+
{
74+
tile.faceRight = false;
75+
}
76+
6277
right.faceLeft = !tileCollides;
6378
}
6479

65-
if (tile && !tile.collides) { tile.resetFaces(); }
80+
if (tile && !tile.collides)
81+
{
82+
tile.resetFaces();
83+
}
6684

6785
return tile;
6886
};

src/tilemaps/components/CalculateFacesWithin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var GetTilesWithin = require('./GetTilesWithin');
1313
* is mostly used internally.
1414
*
1515
* @function Phaser.Tilemaps.Components.CalculateFacesWithin
16-
* @private
1716
* @since 3.0.0
1817
*
1918
* @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.

src/tilemaps/components/Copy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
1313
* information in the destination region.
1414
*
1515
* @function Phaser.Tilemaps.Components.Copy
16-
* @private
1716
* @since 3.0.0
1817
*
1918
* @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels.
@@ -40,6 +39,7 @@ var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, re
4039
{
4140
var tileX = srcTiles[i].x + offsetX;
4241
var tileY = srcTiles[i].y + offsetY;
42+
4343
if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height)
4444
{
4545
if (layer.data[tileY][tileX])

src/tilemaps/components/CreateFromTiles.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ var ReplaceByIndex = require('./ReplaceByIndex');
1616
* Sprites, but want to replace the tile itself with a floor tile or similar once converted.
1717
*
1818
* @function Phaser.Tilemaps.Components.CreateFromTiles
19-
* @private
2019
* @since 3.0.0
2120
*
22-
* @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from.
23-
* @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array.
21+
* @param {(number|number[])} indexes - The tile index, or array of indexes, to create Sprites from.
22+
* @param {(number|number[])} replacements - The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array.
2423
* @param {Phaser.Types.GameObjects.Sprite.SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite).
2524
* @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within.
2625
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY
@@ -32,9 +31,13 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came
3231
{
3332
if (spriteConfig === undefined) { spriteConfig = {}; }
3433

35-
if (!Array.isArray(indexes)) { indexes = [ indexes ]; }
34+
if (!Array.isArray(indexes))
35+
{
36+
indexes = [ indexes ];
37+
}
3638

3739
var tilemapLayer = layer.tilemapLayer;
40+
3841
if (scene === undefined) { scene = tilemapLayer.scene; }
3942
if (camera === undefined) { camera = scene.cameras.main; }
4043

@@ -51,8 +54,7 @@ var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, came
5154
spriteConfig.x = TileToWorldX(tile.x, camera, layer);
5255
spriteConfig.y = TileToWorldY(tile.y, camera, layer);
5356

54-
var sprite = scene.make.sprite(spriteConfig);
55-
sprites.push(sprite);
57+
sprites.push(scene.make.sprite(spriteConfig));
5658
}
5759
}
5860

src/tilemaps/components/CullTiles.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var SnapCeil = require('../../math/snap/SnapCeil');
1111
* Returns the tiles in the given layer that are within the camera's viewport. This is used internally.
1212
*
1313
* @function Phaser.Tilemaps.Components.CullTiles
14-
* @private
1514
* @since 3.0.0
1615
*
1716
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.

src/tilemaps/components/Fill.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var SetTileCollision = require('./SetTileCollision');
1414
* Collision information in the region will be recalculated.
1515
*
1616
* @function Phaser.Tilemaps.Components.Fill
17-
* @private
1817
* @since 3.0.0
1918
*
2019
* @param {integer} index - The tile index to fill the area with.

src/tilemaps/components/FilterTiles.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ var GetTilesWithin = require('./GetTilesWithin');
1212
* true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS.
1313
*
1414
* @function Phaser.Tilemaps.Components.FilterTiles
15-
* @private
1615
* @since 3.0.0
1716
*
1817
* @param {function} callback - The callback. Each tile in the given area will be passed to this
@@ -28,7 +27,7 @@ var GetTilesWithin = require('./GetTilesWithin');
2827
* @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side.
2928
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face.
3029
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
31-
*
30+
*
3231
* @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles.
3332
*/
3433
var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
@@ -39,4 +38,3 @@ var FilterTiles = function (callback, context, tileX, tileY, width, height, filt
3938
};
4039

4140
module.exports = FilterTiles;
42-

src/tilemaps/components/FindByIndex.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* the top-left.
1313
*
1414
* @function Phaser.Tilemaps.Components.FindByIndex
15-
* @private
1615
* @since 3.0.0
1716
*
1817
* @param {integer} index - The tile index value to search for.

src/tilemaps/components/FindTile.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var GetTilesWithin = require('./GetTilesWithin');
2222
* true. Similar to Array.prototype.find in vanilla JS.
2323
*
2424
* @function Phaser.Tilemaps.Components.FindTile
25-
* @private
2625
* @since 3.0.0
2726
*
2827
* @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter.

0 commit comments

Comments
 (0)