Phaser API Documentation

  Version: 
Filter
Namespace: Size
Phaser.Physics.Arcade.Components.Size

Methods

setOffset(x, [y])
Focus
Focus

Description:

Sets the body offset. This allows you to adjust the difference between the center of the body and the x and y coordinates of the parent Game Object.

Parameters:

name type arguments Default description
x number

The amount to offset the body from the parent Game Object along the x-axis.

y number <optional> x

The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis.

Returns:
Description:

This Game Object.

Since: 3.0.0
Focus
Focus
setSize(width, height, [center])
Focus
Focus

Description:

DEPRECATED: Please use setBodySize instead.

Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object.

Parameters:

name type arguments Default description
width number

The new width of the physics body, in pixels.

height number

The new height of the physics body, in pixels.

center boolean <optional> true

Should the body be re-positioned so its center aligns with the parent Game Object?

Returns:
Description:

This Game Object.

Since: 3.0.0
Focus
Focus
setBodySize(width, height, [center])
Focus
Focus

Description:

Sets the size of this physics body. Setting the size does not adjust the dimensions of the parent Game Object.

Parameters:

name type arguments Default description
width number

The new width of the physics body, in pixels.

height number

The new height of the physics body, in pixels.

center boolean <optional> true

Should the body be re-positioned so its center aligns with the parent Game Object?

Returns:
Description:

This Game Object.

Since: 3.24.0
Focus
Focus
setCircle(radius, [offsetX], [offsetY])
Focus
Focus

Description:

Sets this physics body to use a circle for collision instead of a rectangle.

Parameters:

name type arguments description
radius number

The radius of the physics body, in pixels.

offsetX number <optional>

The amount to offset the body from the parent Game Object along the x-axis.

offsetY number <optional>

The amount to offset the body from the parent Game Object along the y-axis.

Returns:
Description:

This Game Object.

Since: 3.0.0
Focus
Focus