PokéRogue
    Preparing search index...

    Provides methods used for controlling the size and offset of the Arcade Physics body belonging to a Game Object. The physics body dimensions are independent of the Game Object's visual dimensions, allowing the collision area to be smaller, larger, or offset from the sprite. This component is mixed into Arcade Physics-enabled Game Objects and should not be used directly.

    interface Size {
        setBodySize(width: number, height: number, center?: boolean): this;
        setCircle(radius: number, offsetX?: number, offsetY?: number): this;
        setOffset(x: number, y?: number): this;
        setSize(width: number, height: number, center?: boolean): this;
    }

    Implemented by

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

      Parameters

      • width: number

        The new width of the physics body, in pixels.

      • height: number

        The new height of the physics body, in pixels.

      • Optionalcenter: boolean

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

      Returns this

      This Game Object.

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

      Parameters

      • radius: number

        The radius of the physics body, in pixels.

      • OptionaloffsetX: number

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

      • OptionaloffsetY: number

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

      Returns this

      This Game Object.

    • 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

      • x: number

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

      • Optionaly: number

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

      Returns this

      This Game Object.

    • 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

      • width: number

        The new width of the physics body, in pixels.

      • height: number

        The new height of the physics body, in pixels.

      • Optionalcenter: boolean

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

      Returns this

      This Game Object.