API Docs for: 1.0.1

Grape.Mouse Class

Can decide whether the mouse is over it (in any view). If the mouse enters or leaves, mouseOver and mouseOut events are emitted. When global mouse events are emitted (keyPress.mouseLeft, etc.) and the mouse is over the instance, the event is emitted locally. This class works when AABB interface is implemented.

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

isMouseOver

() Boolean

Returns the mouse is over the instance in any view.

Returns:

Boolean:

true, if mouse is over the instance in any view.

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.

Events

<mouse events>

Fires the global mouse event locally, when a global mouse event is emitted and the mouse is over the instance.

mouseOut

When the mouse enters, this event is emitted.

mouseOut

When the mouse leaves, this event is emitted.