Skip to content

Commit e974ff4

Browse files
committed
Removed Circle functions and updated setSize docs.
1 parent 9b9e398 commit e974ff4

1 file changed

Lines changed: 13 additions & 47 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -625,17 +625,24 @@ Phaser.Physics.Arcade.Body.prototype = {
625625

626626
/**
627627
* You can modify the size of the physics Body to be any dimension you need.
628-
* So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which
629-
* is the position of the Body relative to the top-left of the Sprite.
628+
* This allows you to make it smaller, or larger, than the parent Sprite.
629+
* You can also control the x and y offset of the Body. This is the position of the
630+
* Body relative to the top-left of the Sprite _texture_.
630631
*
631-
* Calling `setSize` will have no effect if you have previously used `Body.setCircle`. To change a collision
632-
* circle use `setCircle` instead.
632+
* For example: If you have a Sprite with a texture that is 80x100 in size,
633+
* and you want the physics body to be 32x32 pixels in the middle of the texture, you would do:
634+
*
635+
* `setSize(32, 32, 24, 34)`
636+
*
637+
* Where the first two parameters is the new Body size (32x32 pixels).
638+
* 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34
639+
* is the vertical offset.
633640
*
634641
* @method Phaser.Physics.Arcade.Body#setSize
635642
* @param {number} width - The width of the Body.
636643
* @param {number} height - The height of the Body.
637-
* @param {number} [offsetX] - The X offset of the Body from the Sprite position.
638-
* @param {number} [offsetY] - The Y offset of the Body from the Sprite position.
644+
* @param {number} [offsetX] - The X offset of the Body from the top-left of the Sprites texture.
645+
* @param {number} [offsetY] - The Y offset of the Body from the top-left of the Sprites texture.
639646
*/
640647
setSize: function (width, height, offsetX, offsetY) {
641648

@@ -659,47 +666,6 @@ Phaser.Physics.Arcade.Body.prototype = {
659666

660667
},
661668

662-
/**
663-
* Sets this Body as using a circle, of the given radius, for all collision detection instead of a rectangle.
664-
* The radius is given in pixels and is the distance from the center of the circle to the edge.
665-
*
666-
* You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite.
667-
*
668-
* @method Phaser.Physics.Arcade.Body#setCircle
669-
* @param {number} [radius] - The radius of the Body in pixels. Pass a value of zero / undefined, to stop the Body using a circle for collision.
670-
* @param {number} [offsetX] - The X offset of the Body from the Sprite position.
671-
* @param {number} [offsetY] - The Y offset of the Body from the Sprite position.
672-
*/
673-
setCircle: function (radius, offsetX, offsetY) {
674-
675-
if (offsetX === undefined) { offsetX = this.offset.x; }
676-
if (offsetY === undefined) { offsetY = this.offset.y; }
677-
678-
if (radius > 0)
679-
{
680-
this.isCircle = true;
681-
this.radius = radius;
682-
683-
this.sourceWidth = radius * 2;
684-
this.sourceHeight = radius * 2;
685-
686-
this.width = this.sourceWidth * this._sx;
687-
this.height = this.sourceHeight * this._sy;
688-
689-
this.halfWidth = Math.floor(this.width / 2);
690-
this.halfHeight = Math.floor(this.height / 2);
691-
692-
this.offset.setTo(offsetX, offsetY);
693-
694-
this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
695-
}
696-
else
697-
{
698-
this.isCircle = false;
699-
}
700-
701-
},
702-
703669
/**
704670
* Resets all Body values (velocity, acceleration, rotation, etc)
705671
*

0 commit comments

Comments
 (0)