@@ -20,6 +20,7 @@ var GetBounds = {
2020
2121 /**
2222 * Gets the center coordinate of this Game Object, regardless of origin.
23+ * The returned point is calculated in local space and does not factor in any parent containers
2324 *
2425 * @method Phaser.GameObjects.Components.GetBounds#getCenter
2526 * @since 3.0.0
@@ -42,6 +43,7 @@ var GetBounds = {
4243
4344 /**
4445 * Gets the top-left corner coordinate of this Game Object, regardless of origin.
46+ * The returned point is calculated in local space and does not factor in any parent containers
4547 *
4648 * @method Phaser.GameObjects.Components.GetBounds#getTopLeft
4749 * @since 3.0.0
@@ -69,6 +71,7 @@ var GetBounds = {
6971
7072 /**
7173 * Gets the top-right corner coordinate of this Game Object, regardless of origin.
74+ * The returned point is calculated in local space and does not factor in any parent containers
7275 *
7376 * @method Phaser.GameObjects.Components.GetBounds#getTopRight
7477 * @since 3.0.0
@@ -96,6 +99,7 @@ var GetBounds = {
9699
97100 /**
98101 * Gets the bottom-left corner coordinate of this Game Object, regardless of origin.
102+ * The returned point is calculated in local space and does not factor in any parent containers
99103 *
100104 * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft
101105 * @since 3.0.0
@@ -123,6 +127,7 @@ var GetBounds = {
123127
124128 /**
125129 * Gets the bottom-right corner coordinate of this Game Object, regardless of origin.
130+ * The returned point is calculated in local space and does not factor in any parent containers
126131 *
127132 * @method Phaser.GameObjects.Components.GetBounds#getBottomRight
128133 * @since 3.0.0
@@ -167,36 +172,66 @@ var GetBounds = {
167172
168173 // We can use the output object to temporarily store the x/y coords in:
169174
170- this . getTopLeft ( output ) ;
175+ var TLx , TLy , TRx , TRy , BLx , BLy , BRx , BRy ;
171176
172- var TLx = output . x ;
173- var TLy = output . y ;
177+ // Instead of doing a check if parent container is
178+ // defined per corner we only do it once.
179+ if ( this . parentContainer )
180+ {
181+ var parentMatrix = this . parentContainer . getWorldTransformMatrix ( ) ;
182+
183+ this . getTopLeft ( output ) ;
184+ parentMatrix . transformPoint ( output . x , output . y , output ) ;
185+
186+ TLx = output . x ;
187+ TLy = output . y ;
188+
189+ this . getTopRight ( output ) ;
190+ parentMatrix . transformPoint ( output . x , output . y , output ) ;
191+
192+ TRx = output . x ;
193+ TRy = output . y ;
194+
195+ this . getBottomLeft ( output ) ;
196+ parentMatrix . transformPoint ( output . x , output . y , output ) ;
197+
198+ BLx = output . x ;
199+ BLy = output . y ;
200+
201+ this . getBottomRight ( output ) ;
202+ parentMatrix . transformPoint ( output . x , output . y , output ) ;
174203
175- this . getTopRight ( output ) ;
204+ BRx = output . x ;
205+ BRy = output . y ;
206+ }
207+ else
208+ {
209+ this . getTopLeft ( output ) ;
210+
211+ TLx = output . x ;
212+ TLy = output . y ;
176213
177- var TRx = output . x ;
178- var TRy = output . y ;
214+ this . getTopRight ( output ) ;
179215
180- this . getBottomLeft ( output ) ;
216+ TRx = output . x ;
217+ TRy = output . y ;
181218
182- var BLx = output . x ;
183- var BLy = output . y ;
219+ this . getBottomLeft ( output ) ;
184220
185- this . getBottomRight ( output ) ;
221+ BLx = output . x ;
222+ BLy = output . y ;
186223
187- var BRx = output . x ;
188- var BRy = output . y ;
224+ this . getBottomRight ( output ) ;
225+
226+ BRx = output . x ;
227+ BRy = output . y ;
228+ }
189229
190230 output . x = Math . min ( TLx , TRx , BLx , BRx ) ;
191231 output . y = Math . min ( TLy , TRy , BLy , BRy ) ;
192232 output . width = Math . max ( TLx , TRx , BLx , BRx ) - output . x ;
193233 output . height = Math . max ( TLy , TRy , BLy , BRy ) - output . y ;
194234
195- if ( this . parentContainer )
196- {
197- // Clearly something needs to happen here :)
198- }
199-
200235 return output ;
201236 }
202237
0 commit comments