JSDoc fixes

This commit is contained in:
Richard Davey 2020-11-23 10:48:24 +00:00
parent 417f7684c3
commit 8698a03bad
35 changed files with 106 additions and 133 deletions

View file

@ -15,9 +15,8 @@
* @since 3.0.0
*
* @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 {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the
* bottom-right. Otherwise it scans from the top-left.
* @param {number} skip - The number of times to skip a matching tile before returning.
* @param {boolean} reverse - If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*
* @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index.

View file

@ -14,7 +14,7 @@ var IsInLayerBounds = require('./IsInLayerBounds');
*
* @param {number} tileX - X position to get the tile from (given in tile units, not pixels).
* @param {number} 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 - 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 were invalid.

View file

@ -17,12 +17,11 @@ var point = new Vector2();
*
* @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] - The Camera to use when calculating the tile index from the world values.
* @param {boolean} nonNull - 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 - 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
* were invalid.
* @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid.
*/
var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer)
{

View file

@ -18,7 +18,7 @@ var point = new Vector2();
*
* @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] - The Camera to use when factoring in which tiles to return.
* @param {Phaser.Cameras.Scene2D.Camera} 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} Returns a boolean, or null if the layer given was invalid.

View file

@ -16,15 +16,15 @@ var Vector2 = require('../../math/Vector2');
*
* @param {number} tileX - The x coordinate, in tiles, not pixels.
* @param {number} 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.Math.Vector2} point - A Vector2 to store the coordinates in. If not given a new Vector2 is created.
* @param {Phaser.Cameras.Scene2D.Camera} 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.
*/
var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
{
if (point === undefined) { point = new Vector2(); }
if (!point) { point = new Vector2(); }
var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight;
@ -35,7 +35,7 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX);

View file

@ -12,7 +12,7 @@
* @since 3.50.0
*
* @param {number} tileY - The y 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.Cameras.Scene2D.Camera} 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 world coordinates.

View file

@ -16,17 +16,16 @@ var Vector2 = require('../../math/Vector2');
*
* @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 coordinates 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 {boolean} snapToFloor - Whether or not to round the tile coordinates 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 - 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.
*/
var HexagonalWorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
if (point === undefined) { point = new Vector2(); }
if (!point) { point = new Vector2(); }
var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight;
@ -34,7 +33,7 @@ var HexagonalWorldToTileXY = function (worldX, worldY, snapToFloor, point, camer
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
// Find the world position relative to the static or dynamic layer's top left origin,
// factoring in the camera's vertical scroll

View file

@ -12,22 +12,20 @@
* @since 3.50.0
*
* @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 {boolean} snapToFloor - Whether or not to round the tile coordinate down to the nearest integer.
* @param {Phaser.Cameras.Scene2D.Camera} 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.
*/
var HexagonalWorldToTileY = function (worldY, snapToFloor, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
var tileHeight = layer.baseTileHeight;
var tilemapLayer = layer.tilemapLayer;
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
// Find the world position relative to the static or dynamic layer's top left origin,
// factoring in the camera's vertical scroll

View file

@ -16,15 +16,15 @@ var Vector2 = require('../../math/Vector2');
*
* @param {number} tileX - The x coordinate, in tiles, not pixels.
* @param {number} 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.Math.Vector2} point - A Vector2 to store the coordinates in. If not given a new Vector2 is created.
* @param {Phaser.Cameras.Scene2D.Camera} 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.
*/
var IsometricTileToWorldXY = function (tileX, tileY, point, camera, layer)
{
if (point === undefined) { point = new Vector2(); }
if (!point) { point = new Vector2(); }
var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight;
@ -35,7 +35,7 @@ var IsometricTileToWorldXY = function (tileX, tileY, point, camera, layer)
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX);

View file

@ -16,17 +16,16 @@ var Vector2 = require('../../math/Vector2');
*
* @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 {boolean} snapToFloor - 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 - 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.
*/
var IsometricWorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
if (point === undefined) { point = new Vector2(); }
if (!point) { point = new Vector2(); }
var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight;
@ -34,7 +33,7 @@ var IsometricWorldToTileXY = function (worldX, worldY, snapToFloor, point, camer
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
// Find the world position relative to the static or dynamic layer's top left origin,
// factoring in the camera's vertical scroll

View file

@ -21,15 +21,13 @@ var SetTileCollision = require('./SetTileCollision');
* @param {(number|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object.
* @param {number} tileX - The x coordinate, in tiles, not pixels.
* @param {number} tileY - The y coordinate, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {boolean} recalculateFaces - `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.
*/
var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer)
{
if (recalculateFaces === undefined) { recalculateFaces = true; }
if (!IsInLayerBounds(tileX, tileY, layer))
{
return null;

View file

@ -21,8 +21,8 @@ var point = new Vector2();
* @param {(number|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object.
* @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 {boolean} recalculateFaces - `true` if the faces data should be recalculated.
* @param {Phaser.Cameras.Scene2D.Camera} 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

@ -20,13 +20,11 @@ var PutTileAt = require('./PutTileAt');
* @param {(number[]|number[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place.
* @param {number} tileX - The x coordinate, in tiles, not pixels.
* @param {number} tileY - The y coordinate, in tiles, not pixels.
* @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated.
* @param {boolean} recalculateFaces - `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)
{
if (recalculateFaces === undefined) { recalculateFaces = true; }
if (!Array.isArray(tilesArray))
{
return null;

View file

@ -17,11 +17,11 @@ var GetRandom = require('../../utils/array/GetRandom');
* @function Phaser.Tilemaps.Components.Randomize
* @since 3.0.0
*
* @param {number} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {number} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {number[]} [indexes] - An array of indexes to randomly draw from during randomization.
* @param {number} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} width - How many tiles wide from the `tileX` index the area will be.
* @param {number} height - How many tiles tall from the `tileY` index the area will be.
* @param {number[]} indexes - An array of indexes to randomly draw from during randomization.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
*/
var Randomize = function (tileX, tileY, width, height, indexes, layer)
@ -30,7 +30,7 @@ var Randomize = function (tileX, tileY, width, height, indexes, layer)
var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer);
// If no indices are given, then find all the unique indexes within the specified region
if (indexes === undefined)
if (!indexes)
{
indexes = [];

View file

@ -17,17 +17,14 @@ var CalculateFacesAt = require('./CalculateFacesAt');
*
* @param {number} tileX - The x coordinate.
* @param {number} 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] - `true` if the faces data should be recalculated.
* @param {boolean} replaceWithNull - 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` 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.
*/
var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer)
{
if (replaceWithNull === undefined) { replaceWithNull = false; }
if (recalculateFaces === undefined) { recalculateFaces = true; }
if (!IsInLayerBounds(tileX, tileY, layer))
{
return null;

View file

@ -18,9 +18,9 @@ var point = new Vector2();
*
* @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 {boolean} replaceWithNull - 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` if the faces data should be recalculated.
* @param {Phaser.Cameras.Scene2D.Camera} 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

@ -16,10 +16,10 @@ var GetTilesWithin = require('./GetTilesWithin');
*
* @param {number} findIndex - The index of the tile to search for.
* @param {number} newIndex - The index of the tile to replace it with.
* @param {number} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {number} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {number} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} width - How many tiles wide from the `tileX` index the area will be.
* @param {number} 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 ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer)

View file

@ -17,16 +17,13 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex');
* @since 3.0.0
*
* @param {(number|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 - If true it will enable collision. If false it will clear collision.
* @param {boolean} recalculateFaces - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {boolean} updateLayer - If true, updates the current tiles on the layer. Set to
* false if no tiles have been placed for significant performance boost.
* @param {boolean} [updateLayer=true] - If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost.
*/
var SetCollision = function (indexes, collides, recalculateFaces, layer, updateLayer)
{
if (collides === undefined) { collides = true; }
if (recalculateFaces === undefined) { recalculateFaces = true; }
if (!Array.isArray(indexes)) { indexes = [ indexes ]; }
if (updateLayer === undefined) { updateLayer = true; }

View file

@ -19,16 +19,13 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex');
*
* @param {number} start - The first index of the tile to be set for collision.
* @param {number} 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 - If true it will enable collision. If false it will clear collision.
* @param {boolean} recalculateFaces - Whether or not to recalculate the tile faces after the update.
* @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon.
* @param {boolean} [updateLayer=true] - If true, updates the current tiles on the layer. Set to
* false if no tiles have been placed for significant performance boost.
* @param {boolean} [updateLayer=true] - If true, updates the current tiles on the layer. Set to false if no tiles have been placed for significant performance boost.
*/
var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer, updateLayer)
{
if (collides === undefined) { collides = true; }
if (recalculateFaces === undefined) { recalculateFaces = true; }
if (updateLayer === undefined) { updateLayer = true; }
if (start > stop)

View file

@ -17,14 +17,12 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex');
* @since 3.0.0
*
* @param {number[]} 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 - If true it will enable collision. If false it will clear collision.
* @param {boolean} recalculateFaces - 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)
{
if (collides === undefined) { collides = true; }
if (recalculateFaces === undefined) { recalculateFaces = true; }
if (!Array.isArray(indexes)) { indexes = [ indexes ]; }
// Note: this only updates layer.collideIndexes for tile indexes found currently in the layer
@ -33,6 +31,7 @@ var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, lay
for (var tx = 0; tx < layer.width; tx++)
{
var tile = layer.data[ty][tx];
if (tile && indexes.indexOf(tile.index) === -1)
{
SetTileCollision(tile, collides);

View file

@ -21,15 +21,12 @@ var HasValue = require('../../utils/object/HasValue');
* @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 {boolean} collides - If true it will enable collision. If false it will clear collision.
* @param {boolean} recalculateFaces - 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)
{
if (collides === undefined) { collides = true; }
if (recalculateFaces === undefined) { recalculateFaces = true; }
for (var ty = 0; ty < layer.height; ty++)
{
for (var tx = 0; tx < layer.width; tx++)
@ -43,6 +40,7 @@ var SetCollisionByProperty = function (properties, collides, recalculateFaces, l
if (!HasValue(tile.properties, property)) { continue; }
var values = properties[property];
if (!Array.isArray(values))
{
values = [ values ];

View file

@ -16,15 +16,12 @@ var CalculateFacesWithin = require('./CalculateFacesWithin');
* @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup
* @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 - If true it will enable collision. If false it will clear collision.
* @param {boolean} recalculateFaces - 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)
{
if (collides === undefined) { collides = true; }
if (recalculateFaces === undefined) { recalculateFaces = true; }
for (var ty = 0; ty < layer.height; ty++)
{
for (var tx = 0; tx < layer.width; tx++)

View file

@ -12,7 +12,7 @@
* @since 3.0.0
*
* @param {number} tileIndex - The tile index to set the collision boolean for.
* @param {boolean} [collides=true] - Should the tile index collide or not?
* @param {boolean} collides - 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

@ -14,10 +14,10 @@ var GetTilesWithin = require('./GetTilesWithin');
* @function Phaser.Tilemaps.Components.SetTileLocationCallback
* @since 3.0.0
*
* @param {number} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {number} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {number} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} width - How many tiles wide from the `tileX` index the area will be.
* @param {number} height - 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

@ -16,10 +16,10 @@ var ShuffleArray = require('../../utils/array/Shuffle');
* @function Phaser.Tilemaps.Components.Shuffle
* @since 3.0.0
*
* @param {number} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {number} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {number} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} width - How many tiles wide from the `tileX` index the area will be.
* @param {number} 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 Shuffle = function (tileX, tileY, width, height, layer)

View file

@ -16,15 +16,15 @@ var Vector2 = require('../../math/Vector2');
*
* @param {number} tileX - The x coordinate, in tiles, not pixels.
* @param {number} 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.Math.Vector2} point - A Vector2 to store the coordinates in. If not given a new Vector2 is created.
* @param {Phaser.Cameras.Scene2D.Camera} 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.
*/
var StaggeredTileToWorldXY = function (tileX, tileY, point, camera, layer)
{
if (point === undefined) { point = new Vector2(); }
if (!point) { point = new Vector2(); }
var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight;
@ -35,7 +35,7 @@ var StaggeredTileToWorldXY = function (tileX, tileY, point, camera, layer)
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX);

View file

@ -12,7 +12,7 @@
* @since 3.50.0
*
* @param {number} tileY - The y 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.Cameras.Scene2D.Camera} 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 world coordinates.

View file

@ -16,17 +16,16 @@ var Vector2 = require('../../math/Vector2');
*
* @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 {boolean} snapToFloor - 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 - 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.
*/
var StaggeredWorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
if (point === undefined) { point = new Vector2(); }
if (!point) { point = new Vector2(); }
var tileWidth = layer.baseTileWidth;
var tileHeight = layer.baseTileHeight;
@ -34,7 +33,7 @@ var StaggeredWorldToTileXY = function (worldX, worldY, snapToFloor, point, camer
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
// Find the world position relative to the static or dynamic layer's top left origin,
// factoring in the camera's vertical scroll

View file

@ -12,22 +12,20 @@
* @since 3.50.0
*
* @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 {boolean} snapToFloor - Whether or not to round the tile coordinate down to the nearest integer.
* @param {Phaser.Cameras.Scene2D.Camera} 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.
*/
var StaggeredWorldToTileY = function (worldY, snapToFloor, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
var tileHeight = layer.baseTileHeight;
var tilemapLayer = layer.tilemapLayer;
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
// Find the world position relative to the static or dynamic layer's top left origin,
// factoring in the camera's vertical scroll

View file

@ -16,10 +16,10 @@ var GetTilesWithin = require('./GetTilesWithin');
*
* @param {number} tileA - First tile index.
* @param {number} tileB - Second tile index.
* @param {number} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {number} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be.
* @param {number} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} width - How many tiles wide from the `tileX` index the area will be.
* @param {number} 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 SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer)

View file

@ -12,7 +12,7 @@
* @since 3.0.0
*
* @param {number} 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.Cameras.Scene2D.Camera} 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}
@ -25,7 +25,7 @@ var TileToWorldX = function (tileX, camera, layer)
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX);

View file

@ -18,15 +18,15 @@ var Vector2 = require('../../math/Vector2');
*
* @param {number} tileX - The x coordinate, in tiles, not pixels.
* @param {number} 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.Math.Vector2} point - A Vector2 to store the coordinates in. If not given a new Vector2 is created.
* @param {Phaser.Cameras.Scene2D.Camera} 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.
*/
var TileToWorldXY = function (tileX, tileY, point, camera, layer)
{
if (point === undefined) { point = new Vector2(0, 0); }
if (!point) { point = new Vector2(0, 0); }
point.x = TileToWorldX(tileX, camera, layer);
point.y = TileToWorldY(tileY, camera, layer);

View file

@ -12,7 +12,7 @@
* @since 3.0.0
*
* @param {number} tileY - The y 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.Cameras.Scene2D.Camera} 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 world coordinates.
@ -25,7 +25,7 @@ var TileToWorldY = function (tileY, camera, layer)
if (tilemapLayer)
{
if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; }
if (!camera) { camera = tilemapLayer.scene.cameras.main; }
layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY));

View file

@ -24,23 +24,24 @@ var GetTilesWithin = require('./GetTilesWithin');
* @function Phaser.Tilemaps.Components.WeightedRandomize
* @since 3.0.0
*
* @param {number} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be.
* @param {number} [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
* @param {number} tileX - The left most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} tileY - The top most tile index (in tile coordinates) to use as the origin of the area.
* @param {number} width - How many tiles wide from the `tileX` index the area will be.
* @param {number} height - 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 - The Tilemap Layer to act upon.
*/
var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer)
{
if (weightedIndexes === undefined) { return; }
if (!weightedIndexes) { return; }
var i;
var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer);
var weightTotal = 0;
for (i = 0; i < weightedIndexes.length; i++)
{
weightTotal += weightedIndexes[i].weight;

View file

@ -18,16 +18,16 @@ var Vector2 = require('../../math/Vector2');
*
* @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 {boolean} snapToFloor - 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 - 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.
*/
var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer)
{
if (point === undefined) { point = new Vector2(0, 0); }
if (!point) { point = new Vector2(0, 0); }
point.x = WorldToTileX(worldX, snapToFloor, camera, layer);
point.y = WorldToTileY(worldY, snapToFloor, camera, layer);