Options
All
  • Public
  • Public/Protected
  • All
Menu

Allows for more precise collision detection.

// Creates a hitbox 4 pixels right and down from the top left of the sprite,
// with a width of 32 pixels and a height of 40 pixels.
player.hitbox = new HitBox(4, 4, 32, 40)

Hierarchy

  • HitBox

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new HitBox(x: number, y: number, width: number, height: number): HitBox
  • Initialize HitBox object.

    Parameters

    • x: number

      X axis offset from top left.

    • y: number

      Y axis offset from top left.

    • width: number

      Width of hitbox.

    • height: number

      Height of hitbox.

    Returns HitBox

Accessors

height

  • get height(): number

width

  • get width(): number

x

  • get x(): number
  • Gets the offset along the X axis from top left.

    Returns number

y

  • get y(): number
  • Gets the offset along the Y axis from top left.

    Returns number

Methods

set

  • set(x: number, y: number, width: number, height: number): void
  • Set new values for the hitbox.

    Parameters

    • x: number

      X axis offset from top left.

    • y: number

      Y axis offset from top left.

    • width: number

      Width of hitbox.

    • height: number

      Height of hitbox.

    Returns void