Merge pull request #6432 from samme/feature/GetBounds-output

Change GetBounds() default output type to Rectangle
This commit is contained in:
Richard Davey 2023-03-26 17:20:47 +01:00 committed by GitHub
commit 3f318580d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@ var GetBottom = require('./GetBottom');
var GetLeft = require('./GetLeft'); var GetLeft = require('./GetLeft');
var GetRight = require('./GetRight'); var GetRight = require('./GetRight');
var GetTop = require('./GetTop'); var GetTop = require('./GetTop');
var Rectangle = require('../../geom/rectangle/Rectangle');
/** /**
* Returns the unrotated bounds of the Game Object as a rectangle. * Returns the unrotated bounds of the Game Object as a rectangle.
@ -16,13 +17,13 @@ var GetTop = require('./GetTop');
* @since 3.24.0 * @since 3.24.0
* *
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. * @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. * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created.
* *
* @return {(Phaser.Geom.Rectangle|object)} - The bounds of the Game Object. * @return {(Phaser.Geom.Rectangle|object)} - The bounds of the Game Object.
*/ */
var GetBounds = function (gameObject, output) var GetBounds = function (gameObject, output)
{ {
if (output === undefined) { output = {}; } if (output === undefined) { output = new Rectangle(); }
var left = GetLeft(gameObject); var left = GetLeft(gameObject);
var top = GetTop(gameObject); var top = GetTop(gameObject);