File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * @author samme
3+ * @copyright 2020 Photon Storm Ltd.
4+ * @license {@link https://opensource.org/licenses/MIT|MIT License }
5+ */
6+
7+ var GetBottom = require ( './GetBottom' ) ;
8+ var GetLeft = require ( './GetLeft' ) ;
9+ var GetRight = require ( './GetRight' ) ;
10+ var GetTop = require ( './GetTop' ) ;
11+
12+ /**
13+ * Returns the unrotated bounds of the Game Object as a rectangle.
14+ *
15+ * @function Phaser.Display.Bounds.GetBounds
16+ * @since 3.24.0
17+ *
18+ * @param {Phaser.GameObjects.GameObject } gameObject - The Game Object to get the bounds value from.
19+ * @param {(Phaser.Geom.Rectangle|object) } [output] - An object to store the values in.
20+ *
21+ * @return {(Phaser.Geom.Rectangle|object) } - The bounds of the Game Object.
22+ */
23+ var GetBounds = function ( gameObject , output )
24+ {
25+ if ( output === undefined ) { output = { } ; }
26+
27+ var left = GetLeft ( gameObject ) ;
28+ var top = GetTop ( gameObject ) ;
29+
30+ output . x = left ;
31+ output . y = top ;
32+ output . width = GetRight ( gameObject ) - left ;
33+ output . height = GetBottom ( gameObject ) - top ;
34+
35+ return output ;
36+ } ;
37+
38+ module . exports = GetBounds ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ module.exports = {
1212
1313 CenterOn : require ( './CenterOn' ) ,
1414 GetBottom : require ( './GetBottom' ) ,
15+ GetBounds : require ( './GetBounds' ) ,
1516 GetCenterX : require ( './GetCenterX' ) ,
1617 GetCenterY : require ( './GetCenterY' ) ,
1718 GetLeft : require ( './GetLeft' ) ,
@@ -25,5 +26,5 @@ module.exports = {
2526 SetLeft : require ( './SetLeft' ) ,
2627 SetRight : require ( './SetRight' ) ,
2728 SetTop : require ( './SetTop' )
28-
29+
2930} ;
You can’t perform that action at this time.
0 commit comments