Physics.Arcade.Body#setCircle()

setCircle(radius, offsetX, offsetY)

Sets this Body as using a circle, of the given radius, for all collision detection instead of a rectangle.
The radius is given in pixels and is the distance from the center of the circle to the edge.

You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite.

To change a Body back to being rectangular again call Body.setSize.

Note: Circular collision only happens with other Arcade Physics bodies, it does not
work against tile maps, where rectangular collision is the only method supported.

Parameters
Name Type Argument Description
radius number <optional>

The radius of the Body in pixels. Pass a value of zero / undefined, to stop the Body using a circle for collision.

offsetX number <optional>

The X offset of the Body from the Sprite position.

offsetY number <optional>

The Y offset of the Body from the Sprite position.

Source code: physics/arcade/Body.js (Line 1084)
doc_phaser
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.