mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
Merge pull request #5207 from samme/feature/display-getBounds
Add Phaser.Display.Bounds.GetBounds()
This commit is contained in:
commit
8080196800
2 changed files with 40 additions and 1 deletions
38
src/display/bounds/GetBounds.js
Normal file
38
src/display/bounds/GetBounds.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* @author samme
|
||||
* @copyright 2020 Photon Storm Ltd.
|
||||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
var GetBottom = require('./GetBottom');
|
||||
var GetLeft = require('./GetLeft');
|
||||
var GetRight = require('./GetRight');
|
||||
var GetTop = require('./GetTop');
|
||||
|
||||
/**
|
||||
* Returns the unrotated bounds of the Game Object as a rectangle.
|
||||
*
|
||||
* @function Phaser.Display.Bounds.GetBounds
|
||||
* @since 3.24.0
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from.
|
||||
* @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in.
|
||||
*
|
||||
* @return {(Phaser.Geom.Rectangle|object)} - The bounds of the Game Object.
|
||||
*/
|
||||
var GetBounds = function (gameObject, output)
|
||||
{
|
||||
if (output === undefined) { output = {}; }
|
||||
|
||||
var left = GetLeft(gameObject);
|
||||
var top = GetTop(gameObject);
|
||||
|
||||
output.x = left;
|
||||
output.y = top;
|
||||
output.width = GetRight(gameObject) - left;
|
||||
output.height = GetBottom(gameObject) - top;
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
module.exports = GetBounds;
|
|
@ -12,6 +12,7 @@ module.exports = {
|
|||
|
||||
CenterOn: require('./CenterOn'),
|
||||
GetBottom: require('./GetBottom'),
|
||||
GetBounds: require('./GetBounds'),
|
||||
GetCenterX: require('./GetCenterX'),
|
||||
GetCenterY: require('./GetCenterY'),
|
||||
GetLeft: require('./GetLeft'),
|
||||
|
@ -25,5 +26,5 @@ module.exports = {
|
|||
SetLeft: require('./SetLeft'),
|
||||
SetRight: require('./SetRight'),
|
||||
SetTop: require('./SetTop')
|
||||
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue