API Docs for: 1.0.1

Grape.Collidable Class

A class, which can have collision events.

Methods

getBottom

() Number

Returns the bottom axis.

Returns:

Number:

the bottom axis

getBounds

() Object

Gets the left, right, top, bottom coordinates at once.

Returns:

Object:

The bounding box coordinates, should contain "left", "right", "top" and "bottom" properties

getGame

() Grape.Game | Null

Gets the current game instance through the current layer.

Returns:

Grape.Game | Null:

The current game, or null, if the lookup fails.

getHeight

() Number

Returns the height (bottom - top).

Returns:

Number:

the height, should be bottom - top

getLayer

() Grape.Layer

Returns the layer the instance is added to.

Returns:

Grape.Layer:

The layer

getLeft

() Number

Returns the left axis.

Returns:

Number:

the left axis

getRight

() Number

Returns the right axis.

Returns:

Number:

the right axis

getScene

() Grape.Scene | Null

Gets the root layer.

Returns:

Grape.Scene | Null:

The root layer, or null, if the lookup fails.

getTop

() Number

Returns the top axis.

Returns:

Number:

the top axis

getWidth

() Number

Returns the width (right - left).

Returns:

Number:

the width, should be right - left

onGlobal

(
  • event
  • handler
)

Subscribes to an event on the layer the instance is added to. If the instance is not yet added to any layers, it will subscribe when added.

Parameters:

  • event String

    Event

  • handler Function

    Event listener

remove

()

Removes the instance from the layer.