Skip to content

Commit dabe3d2

Browse files
committed
Tilemap: more jsdocs
1 parent 10d7be0 commit dabe3d2

5 files changed

Lines changed: 44 additions & 13 deletions

File tree

v3/src/gameobjects/tilemap/components/CalculateFacesWithin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ var GetTileAt = require('./GetTileAt');
22
var GetTilesWithin = require('./GetTilesWithin');
33

44
/**
5-
* Calculates interesting faces within the rectangular area specified (in tile coordinates).
6-
* Interesting faces are used internally for optimizing collisions against tiles. This method is
7-
* mostly used internally.
5+
* Calculates interesting faces within the rectangular area specified (in tile coordinates) of the
6+
* layer. Interesting faces are used internally for optimizing collisions against tiles. This method
7+
* is mostly used internally.
88
*
99
* @param {number} [tileX=0] - [description]
1010
* @param {number} [tileY=0] - [description]

v3/src/gameobjects/tilemap/components/Copy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
33

44
/**
55
* Copies the tiles in the source rectangular area to a new destination (all specified in tile
6-
* coordinates). This copies all tile properties & recalculates interesting tile faces in the
7-
* destination region.
6+
* coordinates) within the layer. This copies all tile properties & recalculates interesting tile
7+
* faces in the destination region.
88
*
99
* @param {number} srcTileX - [description]
1010
* @param {number} srcTileY - [description]

v3/src/gameobjects/tilemap/components/Fill.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ var GetTilesWithin = require('./GetTilesWithin');
22
var CalculateFacesWithin = require('./CalculateFacesWithin');
33

44
/**
5-
* Sets the tiles in the given rectangular area (in tile coordinates) with the specified index.
6-
* Tiles will be set to collide if the given index is a colliding index. Interesting tile faces in
7-
* the region will be recalculated.
5+
* Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the
6+
* specified index. Tiles will be set to collide if the given index is a colliding index.
7+
* Interesting tile faces in the region will be recalculated.
88
*
99
* @param {number} index - [description]
1010
* @param {number} tileX - [description]
@@ -14,8 +14,6 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
1414
* @param {boolean} [recalculateFaces=true] - [description]
1515
* @param {LayerData} layer - [description]
1616
*/
17-
18-
// Fills indices, not other properties. Does not modify collisions. Matches v2 functionality.
1917
var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer)
2018
{
2119
if (recalculateFaces === undefined) { recalculateFaces = true; }

v3/src/gameobjects/tilemap/components/FindByIndex.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
// Find first tile with given index, or null if nothing found.
2-
// Searches from top left to bottom right.
3-
// Skip a number of matches or reverse to search from bottom-right to top-left.
1+
/**
2+
* Searches the entire map layer for the first tile matching the given index, then returns that Tile
3+
* object. If no match is found, it returns null. The search starts from the top-left tile and
4+
* continues horizontally until it hits the end of the row, then it drops down to the next column.
5+
* If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to
6+
* the top-left.
7+
*
8+
* @param {number} index - The tile index value to search for.
9+
* @param {number} [skip=0] - The number of times to skip a matching tile before returning.
10+
* @param {number} [reverse=false] - If true it will scan the layer in reverse, starting at the
11+
* bottom-right. Otherwise it scans from the top-left.
12+
* @param {LayerData} layer - [description]
13+
* @return {Tile|null} The first (or n skipped) tile with the matching index.
14+
*/
15+
416
var FindByIndex = function (findIndex, skip, reverse, layer)
517
{
618
if (skip === undefined) { skip = 0; }

v3/src/gameobjects/tilemap/components/ForEachTile.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
var GetTilesWithin = require('./GetTilesWithin');
22

3+
/**
4+
* For each tile in the given rectangular area (in tile coordinates) of the layer, run the given
5+
* callback.
6+
*
7+
* @param {number} callback - The callback. Each tile in the given area will be passed to this
8+
* callback as the first and only parameter.
9+
* @param {number} context - The context under which the callback should be run.
10+
* @param {number} [tileX=0]
11+
* @param {number} [tileY=0]
12+
* @param {number} [width=max width based on tileX] - [description]
13+
* @param {number} [height=max height based on tileY] - [description]
14+
* @param {object} [filteringOptions] - Optional filters to apply when getting the tiles.
15+
* @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have
16+
* -1 for an index.
17+
* @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on
18+
* at least one side.
19+
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that
20+
* have at least one interesting face.
21+
* @param {LayerData} layer - [description]
22+
*/
23+
324
var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
425
{
526
var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer);

0 commit comments

Comments
 (0)