Skip to content

Commit af1198d

Browse files
committed
Arcade.Components.Size.setBodySize is a new method available on Arcade Physics Game Objects that allows you to set the body size. This replaces setSize which is now deprecated. Fix phaserjs#4786
1 parent 7d1ca68 commit af1198d

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

  • src/physics/arcade/components

src/physics/arcade/components/Size.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ var Size = {
3333
},
3434

3535
/**
36-
* Sets the size of this physics body. Setting the size does not adjust the dimensions
37-
* of the parent Game Object.
36+
* **DEPRECATED**: Please use `setBodySize` instead.
37+
*
38+
* Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object.
3839
*
3940
* @method Phaser.Physics.Arcade.Components.Size#setSize
4041
* @since 3.0.0
42+
* @deprecated
4143
*
4244
* @param {number} width - The new width of the physics body, in pixels.
4345
* @param {number} height - The new height of the physics body, in pixels.
@@ -52,6 +54,25 @@ var Size = {
5254
return this;
5355
},
5456

57+
/**
58+
* Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object.
59+
*
60+
* @method Phaser.Physics.Arcade.Components.Size#setBodySize
61+
* @since 3.24.0
62+
*
63+
* @param {number} width - The new width of the physics body, in pixels.
64+
* @param {number} height - The new height of the physics body, in pixels.
65+
* @param {boolean} [center=true] - Should the body be re-positioned so its center aligns with the parent Game Object?
66+
*
67+
* @return {this} This Game Object.
68+
*/
69+
setBodySize: function (width, height, center)
70+
{
71+
this.body.setSize(width, height, center);
72+
73+
return this;
74+
},
75+
5576
/**
5677
* Sets this physics body to use a circle for collision instead of a rectangle.
5778
*

0 commit comments

Comments
 (0)