mirror of
https://github.com/photonstorm/phaser
synced 2025-01-12 05:08:54 +00:00
29 lines
871 B
JavaScript
29 lines
871 B
JavaScript
/**
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
*/
|
|
|
|
/**
|
|
* Checks if a given point is inside a Rectangle's bounds.
|
|
*
|
|
* @function Phaser.Geom.Rectangle.Contains
|
|
* @since 3.0.0
|
|
*
|
|
* @param {Phaser.Geom.Rectangle} rect - The Rectangle to check.
|
|
* @param {number} x - The X coordinate of the point to check.
|
|
* @param {number} y - The Y coordinate of the point to check.
|
|
*
|
|
* @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`.
|
|
*/
|
|
var Contains = function (rect, x, y)
|
|
{
|
|
if (rect.width <= 0 || rect.height <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y);
|
|
};
|
|
|
|
module.exports = Contains;
|