phaser/src/tilemaps/components/IsInLayerBounds.js
2019-05-10 16:15:04 +01:00

25 lines
853 B
JavaScript

/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Checks if the given tile coordinates are within the bounds of the layer.
*
* @function Phaser.Tilemaps.Components.IsInLayerBounds
* @private
* @since 3.0.0
*
* @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} `true` if the tile coordinates are within the bounds of the layer, otherwise `false`.
*/
var IsInLayerBounds = function (tileX, tileY, layer)
{
return (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height);
};
module.exports = IsInLayerBounds;