Class: Hitbox

rune.display.Hitbox(obj)

Represents a bounding box for an interactive object. Useful when you want to limit collision detection to a specific part of an interactive object. The class is primarily intended to be used internally by Rune. For example, the DisplayObject class uses an instance of Hitbox to do all of its collision handling.

Constructor

new Hitbox(obj)

Creates a new Hitbox.
Parameters:
Name Type Description
obj rune.display.InteractiveObject The owner of the hitbox.
Source:
See:

Members

(readonly) bottom :number

The sum of the y and height properties.
Type:
  • number
Source:

(readonly) bottomLeft :rune.geom.Point

The location of the hitbox object's bottom-left corner, determined by the values of the left and bottom properties.
Type:
Source:

(readonly) bottomRight :rune.geom.Point

The location of the hitbox object's bottom-right corner, determined by the values of the right and bottom properties.
Type:
Source:

(readonly) center :rune.geom.Point

The center point of the hitbox object.
Type:
Source:

(readonly) centerX :number

The x coordinate of the center of the object.
Type:
  • number
Source:

(readonly) centerY :number

The y coordinate of the center of the object.
Type:
  • number
Source:

debug :boolean

Used to activate debug mode, which illustrates the hitbox as a colored rectangle.
Type:
  • boolean
Default Value:
  • false
Source:

debugColor :string

The line color to use for the debug rectangle.
Type:
  • string
Default Value:
  • rune.util.Palette.GREEN
Source:

(readonly) height :number

The height of the hitbox, in pixels.
Type:
  • number
Source:

left :number

The x coordinate of the top-left corner of the hitbox.
Type:
  • number
Source:

(readonly) previousX :number

The previous x position of the hitbox.
Type:
  • number
Source:

(readonly) previousY :number

The previous y position of the hitbox.
Type:
  • number
Source:
The sum of the x and width properties.
Type:
  • number
Source:

top :number

The y coordinate of the top-left corner of the hitbox.
Type:
  • number
Source:

topLeft :number

The location of the hitbox object's top-left corner, determined by the x and y coordinates of the point.
Type:
  • number
Source:

topRight :number

The location of the hitbox object's top-right corner, determined by the x and y coordinates of the point.
Type:
  • number
Source:

(readonly) width :number

The width of the hitbox, in pixels.
Type:
  • number
Source:

(readonly) x :number

The horizontal coordinate of the hitbox.
Type:
  • number
Source:

(readonly) y :number

The vertical coordinate of the hitbox.
Type:
  • number
Source:

Methods

set(x, y, width, height) → {undefined}

Set the position and size of the hitbox. Note that x and y coordinates are relative to the interactive object that owns the hitbox.
Parameters:
Name Type Description
x number The x position of the hitbox
y number The y position of the hitbox
width number The width of the hitbox
height number The height of the hitbox
Source:
Returns:
Type
undefined