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.
Item Index
Methods
Events
Methods
getBottom
()
Number
Returns the bottom axis.
Returns:
the bottom axis
getBounds
()
Object
Gets the left, right, top, bottom coordinates at once.
Returns:
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:
The current game, or null, if the lookup fails.
getHeight
()
Number
Returns the height (bottom - top).
Returns:
the height, should be bottom - top
getLeft
()
Number
Returns the left axis.
Returns:
the left axis
getRight
()
Number
Returns the right axis.
Returns:
the right axis
getScene
()
Grape.Scene | Null
Gets the root layer.
Returns:
The root layer, or null, if the lookup fails.
getTop
()
Number
Returns the top axis.
Returns:
the top axis
getWidth
()
Number
Returns the width (right - left).
Returns:
the width, should be right - left
isMouseOver
()
Boolean
Returns the mouse is over the instance in any view.
Returns:
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
StringEvent
-
handler
FunctionEvent 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.