Skip to content

Commit 8a78029

Browse files
authored
Merge pull request phaserjs#2728 from samme/issue-2720
Add a hint for resizing Body of scaled Sprites
2 parents 5c143f7 + 792ae12 commit 8a78029

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,14 +1052,20 @@ Phaser.Physics.Arcade.Body.prototype = {
10521052
* 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34
10531053
* is the vertical offset.
10541054
*
1055+
* If you've scaled a Sprite by altering its `width`, `height`, or `scale` and you want to
1056+
* position the Body relative to the Sprite's dimensions (which will differ from its texture's
1057+
* dimensions), you should divide these arguments by the Sprite's current scale:
1058+
*
1059+
* `setSize(32 / sprite.scale.x, 32 / sprite.scale.y)`
1060+
*
10551061
* Calling `setSize` on a Body that has already had `setCircle` will reset all of the Circle
10561062
* properties, making this Body rectangular again.
10571063
*
10581064
* @method Phaser.Physics.Arcade.Body#setSize
10591065
* @param {number} width - The width of the Body.
10601066
* @param {number} height - The height of the Body.
1061-
* @param {number} [offsetX] - The X offset of the Body from the top-left of the Sprites texture.
1062-
* @param {number} [offsetY] - The Y offset of the Body from the top-left of the Sprites texture.
1067+
* @param {number} [offsetX] - The X offset of the Body from the top-left of the Sprite's texture.
1068+
* @param {number} [offsetY] - The Y offset of the Body from the top-left of the Sprite's texture.
10631069
*/
10641070
setSize: function (width, height, offsetX, offsetY) {
10651071

0 commit comments

Comments
 (0)