UNPKG

phaser

Version:

A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.

30 lines (26 loc) 845 B
/** * @author Richard Davey <rich@phaser.io> * @copyright 2013-2025 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|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;