@@ -384,15 +384,18 @@ var Body = new Class({
384384 this . worldBounce = null ;
385385
386386 /**
387- * The custom boundary rectangle to use instead of the world boundary.
388- * If null, the world boundaries are used instead.
387+ * The rectangle used for world boundary collisions.
388+ *
389+ * By default it is set to the world boundary rectangle. Or, if this Body was
390+ * created by a Physics Group, then whatever rectangle that Group defined.
391+ *
392+ * You can also change it by using the `Body.setBoundsRectangle` method.
389393 *
390394 * @name Phaser.Physics.Arcade.Body#customBoundsRectangle
391395 * @type {?Phaser.Geom.Rectangle }
392- * @default null
393- * @since 3.16.1
396+ * @since 3.20
394397 */
395- this . customBoundsRectangle = null ;
398+ this . customBoundsRectangle = world . bounds ;
396399
397400 // If true this Body will dispatch events
398401
@@ -1049,33 +1052,21 @@ var Body = new Class({
10491052 }
10501053 } ,
10511054
1052- /**
1053- * Returns the collision boundary rectangle. Either a custom one, which was
1054- * set with setBoundsRectangle or the default world's bounds.
1055- *
1056- * @method Phaser.Physics.Arcade.Body#getBoundsRectangle
1057- * @since 3.16.1
1058- *
1059- * @return {Phaser.Geom.Rectangle }
1060- */
1061- getBoundsRectangle : function ( )
1062- {
1063- return ( this . customBoundsRectangle || this . world . bounds ) ;
1064- } ,
1065-
10661055 /**
10671056 * Sets a custom collision boundary rectangle. Use if you want to have a custom
10681057 * boundary instead of the world boundaries.
10691058 *
10701059 * @method Phaser.Physics.Arcade.Body#setBoundsRectangle
1071- * @since 3.16.1
1060+ * @since 3.20
10721061 *
1073- * @param {Phaser.Geom.Rectangle } rect - The new boundary rectangle. Pass null to use the default world bounds again.
1074- * @return {Phaser.Physics.Arcade.Body } This Body object.
1062+ * @param {?Phaser.Geom.Rectangle } [bounds] - The new boundary rectangle. Pass `null` to use the World bounds.
1063+ *
1064+ * @return {this } This Body object.
10751065 */
1076- setBoundsRectangle : function ( rect )
1066+ setBoundsRectangle : function ( bounds )
10771067 {
1078- this . customBoundsRectangle = rect ;
1068+ this . customBoundsRectangle = ( ! bounds ) ? this . world . bounds : bounds ;
1069+
10791070 return this ;
10801071 } ,
10811072
@@ -1090,7 +1081,7 @@ var Body = new Class({
10901081 checkWorldBounds : function ( )
10911082 {
10921083 var pos = this . position ;
1093- var bounds = this . getBoundsRectangle ( ) ;
1084+ var bounds = this . customBoundsRectangle ;
10941085 var check = this . world . checkCollision ;
10951086
10961087 var bx = ( this . worldBounce ) ? - this . worldBounce . x : - this . bounce . x ;
0 commit comments