Finished all the Tilemap component descriptions

This commit is contained in:
Richard Davey 2018-09-28 14:32:36 +01:00
parent 43067aa30e
commit 5115847791
42 changed files with 218 additions and 229 deletions

View file

@ -19,21 +19,21 @@ var Tileset = require('./Tileset');
/**
* @callback TilemapFilterCallback
*
* @param {Phaser.GameObjects.GameObject} value - [description]
* @param {number} index - [description]
* @param {Phaser.GameObjects.GameObject[]} array - [description]
* @param {Phaser.GameObjects.GameObject} value - An object found in the filtered area.
* @param {number} index - The index of the object within the array.
* @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found.
*
* @return {Phaser.GameObjects.GameObject} [description]
* @return {Phaser.GameObjects.GameObject} The object.
*/
/**
* @callback TilemapFindCallback
*
* @param {Phaser.GameObjects.GameObject} value - [description]
* @param {number} index - [description]
* @param {Phaser.GameObjects.GameObject[]} array - [description]
* @param {Phaser.GameObjects.GameObject} value - An object found.
* @param {number} index - The index of the object within the array.
* @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found.
*
* @return {boolean} [description]
* @return {boolean} `true` if the callback should be invoked, otherwise `false`.
*/
/**
@ -405,11 +405,23 @@ var Tilemap = new Class({
},
/**
* See component documentation. If no layer specified, the map's current layer is used. This
* cannot be applied to StaticTilemapLayers.
* Copies the tiles in the source rectangular area to a new destination (all specified in tile
* coordinates) within the layer. This copies all tile properties & recalculates collision
* information in the destination region.
*
* If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers.
*
* @method Phaser.Tilemaps.Tilemap#copy
* @since 3.0.0
*
* @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels.
* @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels.
* @param {integer} width - The width of the area to copy, in tiles, not pixels.
* @param {integer} height - The height of the area to copy, in tiles, not pixels.
* @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels.
* @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used.
*
* @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid.
*/
@ -2027,11 +2039,11 @@ var Tilemap = new Class({
* @method Phaser.Tilemaps.Tilemap#shuffle
* @since 3.0.0
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {Phaser.Tilemaps.LayerData} [layer] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used.
*
* @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid.
*/
@ -2062,11 +2074,11 @@ var Tilemap = new Class({
*
* @param {integer} tileA - First tile index.
* @param {integer} tileB - Second tile index.
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {Phaser.Tilemaps.LayerData} [layer] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used.
*
* @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid.
*/
@ -2180,14 +2192,14 @@ var Tilemap = new Class({
* @method Phaser.Tilemaps.Tilemap#weightedRandomize
* @since 3.0.0
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during
* randomization. They should be in the form: { index: 0, weight: 4 } or
* { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes.
* @param {Phaser.Tilemaps.LayerData} [layer] - [description]
* @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used.
*
* @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid.
*/

View file

@ -16,10 +16,10 @@ var GetTilesWithin = require('./GetTilesWithin');
* @private
* @since 3.0.0
*
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {integer} width - [description]
* @param {integer} height - [description]
* @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} width - How many tiles wide from the `tileX` index the area will be.
* @param {integer} height - How many tiles tall from the `tileY` index the area will be.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var CalculateFacesWithin = function (tileX, tileY, width, height, layer)

View file

@ -16,13 +16,13 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
* @private
* @since 3.0.0
*
* @param {integer} srcTileX - [description]
* @param {integer} srcTileY - [description]
* @param {integer} width - [description]
* @param {integer} height - [description]
* @param {integer} destTileX - [description]
* @param {integer} destTileY - [description]
* @param {boolean} [recalculateFaces=true] - [description]
* @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels.
* @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels.
* @param {integer} width - The width of the area to copy, in tiles, not pixels.
* @param {integer} height - The height of the area to copy, in tiles, not pixels.
* @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels.
* @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer)

View file

@ -20,11 +20,8 @@ var ReplaceByIndex = require('./ReplaceByIndex');
* @since 3.0.0
*
* @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from.
* @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.
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e.
* scene.make.sprite).
* @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.
* @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite).
* @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.

View file

@ -16,7 +16,7 @@ var SnapCeil = require('../../math/snap/SnapCeil');
*
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against.
* @param {array} [outputArray] - [description]
* @param {array} [outputArray] - An optional array to store the Tile objects within.
*
* @return {Phaser.Tilemaps.Tile[]} An array of Tile objects.
*/

View file

@ -17,21 +17,20 @@ var SetTileCollision = require('./SetTileCollision');
* @private
* @since 3.0.0
*
* @param {integer} index - [description]
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {boolean} [recalculateFaces=true] - [description]
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {integer} index - The tile index to fill the area with.
* @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} width - How many tiles wide from the `tileX` index the area will be.
* @param {integer} height - How many tiles tall from the `tileY` index the area will be.
* @param {boolean} recalculateFaces - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The tile layer to use. If not given the current layer is used.
*/
var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer)
{
if (recalculateFaces === undefined) { recalculateFaces = true; }
var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1);
var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer);
for (var i = 0; i < tiles.length; i++)
{
tiles[i].index = index;

View file

@ -19,17 +19,14 @@ var GetTilesWithin = require('./GetTilesWithin');
* callback as the first and only parameter. The callback should return true for tiles that pass the
* filter.
* @param {object} [context] - The context under which the callback should be run.
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @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 {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 {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles.
@ -37,6 +34,7 @@ var GetTilesWithin = require('./GetTilesWithin');
var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
{
var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer);
return tiles.filter(callback, context);
};

View file

@ -9,11 +9,11 @@ var GetTilesWithin = require('./GetTilesWithin');
/**
* @callback FindTileCallback
*
* @param {Phaser.Tilemaps.Tile} value - [description]
* @param {number} index - [description]
* @param {Phaser.Tilemaps.Tile[]} array - [description]
* @param {Phaser.Tilemaps.Tile} value - The Tile.
* @param {integer} index - The index of the tile.
* @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects.
*
* @return {boolean} [description]
* @return {boolean} Return `true` if the callback should run, otherwise `false`.
*/
/**
@ -25,20 +25,16 @@ var GetTilesWithin = require('./GetTilesWithin');
* @private
* @since 3.0.0
*
* @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this
* callback as the first and only parameter.
* @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter.
* @param {object} [context] - The context under which the callback should be run.
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @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 {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 {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found

View file

@ -9,9 +9,9 @@ var GetTilesWithin = require('./GetTilesWithin');
/**
* @callback EachTileCallback
*
* @param {Phaser.Tilemaps.Tile} value - [description]
* @param {number} index - [description]
* @param {Phaser.Tilemaps.Tile[]} array - [description]
* @param {Phaser.Tilemaps.Tile} value - The Tile.
* @param {integer} index - The index of the tile.
* @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects.
*/
/**
@ -22,25 +22,22 @@ var GetTilesWithin = require('./GetTilesWithin');
* @private
* @since 3.0.0
*
* @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this
* callback as the first and only parameter.
* @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter.
* @param {object} [context] - The context under which the callback should be run.
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @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 {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 {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer)
{
var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer);
tiles.forEach(callback, context);
};

View file

@ -15,8 +15,7 @@ var IsInLayerBounds = require('./IsInLayerBounds');
*
* @param {integer} tileX - X position to get the tile from (given in tile units, not pixels).
* @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels).
* @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile
* object with an index of -1.
* @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates

View file

@ -17,9 +17,8 @@ var WorldToTileY = require('./WorldToTileY');
*
* @param {number} worldX - X position to get the tile from (given in pixels)
* @param {number} worldY - Y position to get the tile from (given in pixels)
* @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile
* object with an index of -1.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates

View file

@ -21,10 +21,10 @@ var GetFastValue = require('../../utils/object/GetFastValue');
* @private
* @since 3.0.0
*
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {integer} width - [description]
* @param {integer} height - [description]
* @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} width - How many tiles wide from the `tileX` index the area will be.
* @param {integer} height - How many tiles tall from the `tileY` index the area will be.
* @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*

View file

@ -31,13 +31,10 @@ var TriangleToRectangle = function (triangle, rect)
*
* @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates
* @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 {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @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 {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile[]} Array of Tile objects.

View file

@ -15,18 +15,15 @@ var WorldToTileY = require('./WorldToTileY');
* @private
* @since 3.0.0
*
* @param {number} worldX - [description]
* @param {number} worldY - [description]
* @param {number} width - [description]
* @param {number} height - [description]
* @param {number} worldX - The world x coordinate for the top-left of the area.
* @param {number} worldY - The world y coordinate for the top-left of the area.
* @param {number} width - The width of the area.
* @param {number} height - The height of the area.
* @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 {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @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 {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile[]} Array of Tile objects.

View file

@ -14,11 +14,11 @@ var IsInLayerBounds = require('./IsInLayerBounds');
* @private
* @since 3.0.0
*
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {integer} tileX - X position to get the tile from (given in tile units, not pixels).
* @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels).
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {boolean}
* @return {?boolean} Returns a boolean, or null if the layer given was invalid.
*/
var HasTileAt = function (tileX, tileY, layer)
{

View file

@ -18,10 +18,10 @@ var WorldToTileY = require('./WorldToTileY');
*
* @param {number} worldX - The X coordinate of the world position.
* @param {number} worldY - The Y coordinate of the world position.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {boolean}
* @return {?boolean} Returns a boolean, or null if the layer given was invalid.
*/
var HasTileAtWorldXY = function (worldX, worldY, camera, layer)
{

View file

@ -11,11 +11,11 @@
* @private
* @since 3.0.0
*
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {integer} tileX - The x coordinate, in tiles, not pixels.
* @param {integer} tileY - The y coordinate, in tiles, not pixels.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {boolean}
* @return {boolean} `true` if the tile coordinates are within the bounds of the layer, otherwise `false`.
*/
var IsInLayerBounds = function (tileX, tileY, layer)
{

View file

@ -20,9 +20,9 @@ var SetTileCollision = require('./SetTileCollision');
* @since 3.0.0
*
* @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object.
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {boolean} [recalculateFaces=true] - [description]
* @param {integer} tileX - The x coordinate, in tiles, not pixels.
* @param {integer} tileY - The y coordinate, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map.

View file

@ -19,10 +19,10 @@ var WorldToTileY = require('./WorldToTileY');
* @since 3.0.0
*
* @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object.
* @param {integer} worldX - [description]
* @param {integer} worldY - [description]
* @param {boolean} [recalculateFaces=true] - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {number} worldX - The x coordinate, in pixels.
* @param {number} worldY - The y coordinate, in pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map.

View file

@ -18,11 +18,10 @@ var PutTileAt = require('./PutTileAt');
* @private
* @since 3.0.0
*
* @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles
* or tile indexes to place.
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {boolean} [recalculateFaces=true] - [description]
* @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place.
* @param {integer} tileX - The x coordinate, in tiles, not pixels.
* @param {integer} tileY - The y coordinate, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer)

View file

@ -18,10 +18,10 @@ var GetRandom = require('../../utils/array/GetRandom');
* @private
* @since 3.0.0
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/

View file

@ -18,9 +18,8 @@ var CalculateFacesAt = require('./CalculateFacesAt');
*
* @param {integer} tileX - The x coordinate.
* @param {integer} tileY - The y coordinate.
* @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified
* location with null instead of a Tile with an index of -1.
* @param {boolean} [recalculateFaces=true] - [description]
* @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile} The Tile object that was removed.

View file

@ -16,12 +16,11 @@ var WorldToTileY = require('./WorldToTileY');
* @private
* @since 3.0.0
*
* @param {number} worldX - [description]
* @param {number} worldY - [description]
* @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified
* location with null instead of a Tile with an index of -1.
* @param {boolean} [recalculateFaces=true] - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {number} worldX - The x coordinate, in pixels.
* @param {number} worldY - The y coordinate, in pixels.
* @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Tilemaps.Tile} The Tile object that was removed.

View file

@ -15,17 +15,18 @@ var GetTilesWithin = require('./GetTilesWithin');
* @private
* @since 3.0.0
*
* @param {integer} findIndex - [description]
* @param {integer} newIndex - [description]
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} findIndex - The index of the tile to search for.
* @param {integer} newIndex - The index of the tile to replace it with.
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer)
{
var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer);
for (var i = 0; i < tiles.length; i++)
{
if (tiles[i] && tiles[i].index === findIndex)

View file

@ -18,10 +18,8 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex');
* @since 3.0.0
*
* @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear
* collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the
* update.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SetCollision = function (indexes, collides, recalculateFaces, layer)
@ -50,7 +48,10 @@ var SetCollision = function (indexes, collides, recalculateFaces, layer)
}
}
if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); }
if (recalculateFaces)
{
CalculateFacesWithin(0, 0, layer.width, layer.height, layer);
}
};
module.exports = SetCollision;

View file

@ -20,10 +20,8 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex');
*
* @param {integer} start - The first index of the tile to be set for collision.
* @param {integer} stop - The last index of the tile to be set for collision.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear
* collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the
* update.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer)
@ -55,7 +53,10 @@ var SetCollisionBetween = function (start, stop, collides, recalculateFaces, lay
}
}
if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); }
if (recalculateFaces)
{
CalculateFacesWithin(0, 0, layer.width, layer.height, layer);
}
};
module.exports = SetCollisionBetween;

View file

@ -18,10 +18,8 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex');
* @since 3.0.0
*
* @param {integer[]} indexes - An array of the tile indexes to not be counted for collision.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear
* collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the
* update.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer)
@ -44,7 +42,10 @@ var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, lay
}
}
if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); }
if (recalculateFaces)
{
CalculateFacesWithin(0, 0, layer.width, layer.height, layer);
}
};
module.exports = SetCollisionByExclusion;

View file

@ -21,12 +21,9 @@ var HasValue = require('../../utils/object/HasValue');
* @private
* @since 3.0.0
*
* @param {object} properties - An object with tile properties and corresponding values that should
* be checked.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear
* collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the
* update.
* @param {object} properties - An object with tile properties and corresponding values that should be checked.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer)
@ -63,7 +60,10 @@ var SetCollisionByProperty = function (properties, collides, recalculateFaces, l
}
}
if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); }
if (recalculateFaces)
{
CalculateFacesWithin(0, 0, layer.width, layer.height, layer);
}
};
module.exports = SetCollisionByProperty;

View file

@ -17,10 +17,8 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
* @private
* @since 3.0.0
*
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear
* collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the
* update.
* @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision.
* @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer)
@ -47,7 +45,10 @@ var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer
}
}
if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); }
if (recalculateFaces)
{
CalculateFacesWithin(0, 0, layer.width, layer.height, layer);
}
};
module.exports = SetCollisionFromCollisionGroup;

View file

@ -12,8 +12,8 @@
* @private
* @since 3.0.0
*
* @param {integer} tileIndex - [description]
* @param {boolean} [collides=true] - [description]
* @param {integer} tileIndex - The tile index to set the collision boolean for.
* @param {boolean} [collides=true] - Should the tile index collide or not?
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SetLayerCollisionIndex = function (tileIndex, collides, layer)

View file

@ -12,8 +12,8 @@
* @private
* @since 3.0.0
*
* @param {Phaser.Tilemaps.Tile} tile - [description]
* @param {boolean} [collides=true] - [description]
* @param {Phaser.Tilemaps.Tile} tile - The Tile to set the collision on.
* @param {boolean} [collides=true] - Should the tile index collide or not?
*/
var SetTileCollision = function (tile, collides)
{

View file

@ -14,8 +14,7 @@
* @private
* @since 3.0.0
*
* @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a
* collision callback set for.
* @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for.
* @param {function} callback - The callback that will be invoked when the tile is collided with.
* @param {object} callbackContext - The context under which the callback is called.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.

View file

@ -15,10 +15,10 @@ var GetTilesWithin = require('./GetTilesWithin');
* @private
* @since 3.0.0
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {function} callback - The callback that will be invoked when the tile is collided with.
* @param {object} callbackContext - The context under which the callback is called.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.

View file

@ -17,10 +17,10 @@ var ShuffleArray = require('../../utils/array/Shuffle');
* @private
* @since 3.0.0
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var Shuffle = function (tileX, tileY, width, height, layer)

View file

@ -17,10 +17,10 @@ var GetTilesWithin = require('./GetTilesWithin');
*
* @param {integer} tileA - First tile index.
* @param {integer} tileB - Second tile index.
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer)

View file

@ -12,8 +12,8 @@
* @private
* @since 3.0.0
*
* @param {integer} tileX - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {integer} tileX - The x coordinate, in tiles, not pixels.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {number}

View file

@ -17,10 +17,10 @@ var Vector2 = require('../../math/Vector2');
* @private
* @since 3.0.0
*
* @param {integer} tileX - [description]
* @param {integer} tileY - [description]
* @param {Phaser.Math.Vector2} [point] - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {integer} tileX - The x coordinate, in tiles, not pixels.
* @param {integer} tileY - The y coordinate, in tiles, not pixels.
* @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Math.Vector2} The XY location in world coordinates.

View file

@ -12,8 +12,8 @@
* @private
* @since 3.0.0
*
* @param {integer} tileY - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {integer} tileY - The x coordinate, in tiles, not pixels.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {number}

View file

@ -25,10 +25,10 @@ var GetTilesWithin = require('./GetTilesWithin');
* @private
* @since 3.0.0
*
* @param {integer} [tileX=0] - [description]
* @param {integer} [tileY=0] - [description]
* @param {integer} [width=max width based on tileX] - [description]
* @param {integer} [height=max height based on tileY] - [description]
* @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during
* randomization. They should be in the form: { index: 0, weight: 4 } or
* { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes.

View file

@ -12,10 +12,9 @@
* @private
* @since 3.0.0
*
* @param {number} worldX - [description]
* @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the
* nearest integer.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {number} worldX - The x coordinate to be converted, in pixels, not tiles.
* @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {number} The X location in tile units.

View file

@ -17,12 +17,11 @@ var Vector2 = require('../../math/Vector2');
* @private
* @since 3.0.0
*
* @param {number} worldX - [description]
* @param {number} worldY - [description]
* @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the
* nearest integer.
* @param {Phaser.Math.Vector2} [point] - [description]
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {number} worldX - The x coordinate to be converted, in pixels, not tiles.
* @param {number} worldY - The y coordinate to be converted, in pixels, not tiles.
* @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer.
* @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {Phaser.Math.Vector2} The XY location in tile units.

View file

@ -12,10 +12,9 @@
* @private
* @since 3.0.0
*
* @param {number} worldY - [description]
* @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the
* nearest integer.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description]
* @param {number} worldY - The y coordinate to be converted, in pixels, not tiles.
* @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer.
* @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {number} The Y location in tile units.