From c5d7c94cb42300b9f14ab643bb98724fc53c9984 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 20 Nov 2020 16:20:35 +0000 Subject: [PATCH] Fixed JSDocs --- src/tilemaps/components/WorldToTileX.js | 12 ++++-------- src/tilemaps/components/WorldToTileY.js | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/tilemaps/components/WorldToTileX.js b/src/tilemaps/components/WorldToTileX.js index 8b6d8089c..68268d798 100644 --- a/src/tilemaps/components/WorldToTileX.js +++ b/src/tilemaps/components/WorldToTileX.js @@ -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; diff --git a/src/tilemaps/components/WorldToTileY.js b/src/tilemaps/components/WorldToTileY.js index 873130c28..e0db815d8 100644 --- a/src/tilemaps/components/WorldToTileY.js +++ b/src/tilemaps/components/WorldToTileY.js @@ -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;