Fixed JSDocs

This commit is contained in:
Richard Davey 2020-11-20 16:20:35 +00:00
parent 78b75efb8c
commit c5d7c94cb4
2 changed files with 8 additions and 16 deletions

View file

@ -12,22 +12,20 @@
* @since 3.0.0
*
* @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 {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 X location in tile units.
*/
var WorldToTileX = function (worldX, snapToFloor, camera, layer)
{
if (snapToFloor === undefined) { snapToFloor = true; }
var tileWidth = layer.baseTileWidth;
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 horizontal scroll
@ -36,9 +34,7 @@ var WorldToTileX = function (worldX, snapToFloor, camera, layer)
tileWidth *= tilemapLayer.scaleX;
}
return snapToFloor
? Math.floor(worldX / tileWidth)
: worldX / tileWidth;
return (snapToFloor) ? Math.floor(worldX / tileWidth) : worldX / tileWidth;
};
module.exports = WorldToTileX;

View file

@ -12,22 +12,20 @@
* @since 3.0.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 WorldToTileY = 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
@ -36,9 +34,7 @@ var WorldToTileY = function (worldY, snapToFloor, camera, layer)
tileHeight *= tilemapLayer.scaleY;
}
return snapToFloor
? Math.floor(worldY / tileHeight)
: worldY / tileHeight;
return (snapToFloor) ? Math.floor(worldY / tileHeight) : worldY / tileHeight;
};
module.exports = WorldToTileY;