Tilemap: more jsdocs

This commit is contained in:
Michael Hadley 2017-11-26 09:33:19 -06:00
parent 10d7be0785
commit dabe3d27ff
5 changed files with 44 additions and 13 deletions

View file

@ -2,9 +2,9 @@ var GetTileAt = require('./GetTileAt');
var GetTilesWithin = require('./GetTilesWithin');
/**
* Calculates interesting faces within the rectangular area specified (in tile coordinates).
* Interesting faces are used internally for optimizing collisions against tiles. This method is
* mostly used internally.
* Calculates interesting faces within the rectangular area specified (in tile coordinates) of the
* layer. Interesting faces are used internally for optimizing collisions against tiles. This method
* is mostly used internally.
*
* @param {number} [tileX=0] - [description]
* @param {number} [tileY=0] - [description]

View file

@ -3,8 +3,8 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
/**
* Copies the tiles in the source rectangular area to a new destination (all specified in tile
* coordinates). This copies all tile properties & recalculates interesting tile faces in the
* destination region.
* coordinates) within the layer. This copies all tile properties & recalculates interesting tile
* faces in the destination region.
*
* @param {number} srcTileX - [description]
* @param {number} srcTileY - [description]

View file

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

View file

@ -1,6 +1,18 @@
// Find first tile with given index, or null if nothing found.
// Searches from top left to bottom right.
// Skip a number of matches or reverse to search from bottom-right to top-left.
/**
* Searches the entire map layer for the first tile matching the given index, then returns that Tile
* object. If no match is found, it returns null. The search starts from the top-left tile and
* continues horizontally until it hits the end of the row, then it drops down to the next column.
* If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to
* the top-left.
*
* @param {number} index - The tile index value to search for.
* @param {number} [skip=0] - The number of times to skip a matching tile before returning.
* @param {number} [reverse=false] - If true it will scan the layer in reverse, starting at the
* bottom-right. Otherwise it scans from the top-left.
* @param {LayerData} layer - [description]
* @return {Tile|null} The first (or n skipped) tile with the matching index.
*/
var FindByIndex = function (findIndex, skip, reverse, layer)
{
if (skip === undefined) { skip = 0; }

View file

@ -1,5 +1,26 @@
var GetTilesWithin = require('./GetTilesWithin');
/**
* For each tile in the given rectangular area (in tile coordinates) of the layer, run the given
* callback.
*
* @param {number} callback - The callback. Each tile in the given area will be passed to this
* callback as the first and only parameter.
* @param {number} context - The context under which the callback should be run.
* @param {number} [tileX=0]
* @param {number} [tileY=0]
* @param {number} [width=max width based on tileX] - [description]
* @param {number} [height=max height based on tileY] - [description]
* @param {object} [filteringOptions] - Optional filters to apply when getting the tiles.
* @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have
* -1 for an index.
* @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on
* at least one side.
* @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that
* have at least one interesting face.
* @param {LayerData} layer - [description]
*/
var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
{
var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer);