Package de.gurkenlabs.litiengine.input
Interface IMouse
- All Known Implementing Classes:
Mouse
public interface IMouse
The
IMouse
interface is the engine's API for receiving mouse input events.Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
IMouse.MouseClickedListener
This listener interface receives clicked events for the mouse.static interface
IMouse.MouseDraggedListener
This listener interface receives dragged events for the mouse.static interface
IMouse.MouseMovedListener
This listener interface receives moved events for the mouse.static interface
IMouse.MousePressedListener
This listener interface receives pressed events for the mouse.static interface
IMouse.MousePressingListener
This listener interface receives pressing events for the mouse.static interface
IMouse.MouseReleasedListener
This listener interface receives released events for the mouse.Method Summary
Modifier and Type Method Description void
addMouseListener(java.awt.event.MouseListener listener)
Register mouse listener.void
addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Register mouse motion listener.void
clearExplicitListeners()
Removes all registered event listeners from the Mouse instance.java.awt.geom.Point2D
getLocation()
Gets the current location of the mouse within the game window.java.awt.geom.Point2D
getMapLocation()
Gets the location of the mouse on the current map.java.awt.Point
getTile()
Gets the coordinates of the tile on the map on which the mouse is currently located at.boolean
isGrabMouse()
A flag indicating whether the mouse should be grabbed by the game's window.boolean
isLeftButton(java.awt.event.MouseEvent event)
Returns true if the mouse event specifies the left mouse button.boolean
isLeftButtonPressed()
A flag indicating whether the left mouse button is currently pressed.boolean
isPressed()
A flag indicating whether any mouse button is currently pressed.boolean
isRightButton(java.awt.event.MouseEvent event)
Returns true if the mouse event specifies the right mouse button.boolean
isRightButtonPressed()
A flag indicating whether the right mouse button is currently pressed.void
onClicked(IMouse.MouseClickedListener listener)
Adds the specified mouse clicked listener to receive events when the mouse has been clicked.void
onDragged(IMouse.MouseDraggedListener listener)
Adds the specified mouse dragged listener to receive events when the mouse has been dragged.void
onMoved(IMouse.MouseMovedListener listener)
Adds the specified mouse moved listener to receive events when the mouse has been moved.void
onPressed(IMouse.MousePressedListener listener)
Adds the specified mouse pressed listener to receive events when the mouse has been pressed.void
onPressing(IMouse.MousePressingListener listener)
Adds the specified mouse pressing listener to receive continuous events while the mouse is being pressed.void
onReleased(IMouse.MouseReleasedListener listener)
Adds the specified mouse released listener to receive events when the mouse has been released.void
onWheelMoved(java.awt.event.MouseWheelListener listener)
Adds the specified mouse wheel listener to receive events when the mouse wheel has been moved.void
removeMouseClickedListener(IMouse.MouseClickedListener listener)
Unregisters the specified mouse clicked listener.void
removeMouseDraggedListener(IMouse.MouseDraggedListener listener)
Unregisters the specified mouse dragged listener.void
removeMouseListener(java.awt.event.MouseListener listener)
Unregister mouse listener.void
removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
Unregister mouse motion listener.void
removeMouseMovedListener(IMouse.MouseMovedListener listener)
Unregisters the specified mouse moved listener.void
removeMousePressedListener(IMouse.MousePressedListener listener)
Unregisters the specified mouse pressed listener.void
removeMousePressingListener(IMouse.MousePressingListener listener)
Unregisters the specified mouse pressing listener.void
removeMouseReleasedListener(IMouse.MouseReleasedListener listener)
Unregisters the specified mouse released listener.void
removeMouseWheelListener(java.awt.event.MouseWheelListener listener)
Unregisters the specified mouse wheel listener.void
setGrabMouse(boolean grab)
If set to true, the mouse will be locked to the render component of the game.void
setLocation(double x, double y)
Sets the current mouse location to the specified location in the game window.void
setLocation(java.awt.geom.Point2D newLocation)
Sets the current mouse location to the specified location in the game window.
Method Details
onClicked
Adds the specified mouse clicked listener to receive events when the mouse has been clicked.- Parameters:
listener
- The listener to add.- See Also:
MouseListener.mouseClicked(MouseEvent)
,MouseEvent.MOUSE_CLICKED
removeMouseClickedListener
Unregisters the specified mouse clicked listener.- Parameters:
listener
- The listener to remove.
onDragged
Adds the specified mouse dragged listener to receive events when the mouse has been dragged.- Parameters:
listener
- The listener to add.- See Also:
IMouse.MouseDraggedListener.mouseDragged(MouseEvent)
,MouseMotionListener.mouseDragged(MouseEvent)
,MouseEvent.MOUSE_DRAGGED
removeMouseDraggedListener
Unregisters the specified mouse dragged listener.- Parameters:
listener
- The listener to remove.
onMoved
Adds the specified mouse moved listener to receive events when the mouse has been moved.- Parameters:
listener
- The listener to add.- See Also:
MouseMotionListener.mouseMoved(MouseEvent)
,MouseEvent.MOUSE_MOVED
removeMouseMovedListener
Unregisters the specified mouse moved listener.- Parameters:
listener
- The listener to remove.
onPressed
Adds the specified mouse pressed listener to receive events when the mouse has been pressed.- Parameters:
listener
- The listener to add.- See Also:
MouseListener.mousePressed(MouseEvent)
,MouseEvent.MOUSE_PRESSED
removeMousePressedListener
Unregisters the specified mouse pressed listener.- Parameters:
listener
- The listener to remove.
onPressing
Adds the specified mouse pressing listener to receive continuous events while the mouse is being pressed.- Parameters:
listener
- The listener to add.
removeMousePressingListener
Unregisters the specified mouse pressing listener.- Parameters:
listener
- The listener to remove.
onReleased
Adds the specified mouse released listener to receive events when the mouse has been released.- Parameters:
listener
- The listener to add.- See Also:
MouseListener.mouseReleased(MouseEvent)
,MouseEvent.MOUSE_RELEASED
removeMouseReleasedListener
Unregisters the specified mouse released listener.- Parameters:
listener
- The listener to remove.
onWheelMoved
void onWheelMoved(java.awt.event.MouseWheelListener listener)Adds the specified mouse wheel listener to receive events when the mouse wheel has been moved.- Parameters:
listener
- The listener to add.- See Also:
MouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)
,MouseWheelEvent
removeMouseWheelListener
void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)Unregisters the specified mouse wheel listener.- Parameters:
listener
- The listener to remove.
addMouseListener
void addMouseListener(java.awt.event.MouseListener listener)Register mouse listener.- Parameters:
listener
- the listener
removeMouseListener
void removeMouseListener(java.awt.event.MouseListener listener)Unregister mouse listener.- Parameters:
listener
- the listener
addMouseMotionListener
void addMouseMotionListener(java.awt.event.MouseMotionListener listener)Register mouse motion listener.- Parameters:
listener
- the listener
removeMouseMotionListener
void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)Unregister mouse motion listener.- Parameters:
listener
- the listener
clearExplicitListeners
void clearExplicitListeners()Removes all registered event listeners from the Mouse instance. This does not affect registeredMouseListener
,MouseMotionListener
orMouseWheelListener
instances.getLocation
java.awt.geom.Point2D getLocation()Gets the current location of the mouse within the game window.The coordinates are relative to the game window and don't reflect coordinates on the game world.
UsegetMapLocation()
to get a translated position for the current environment.- Returns:
- The current location of the mouse within the game window.
- See Also:
getMapLocation()
getMapLocation
java.awt.geom.Point2D getMapLocation()Gets the location of the mouse on the current map.This translates the current mouse locations to the location on the map by using the current camera.
UsegetLocation()
to get the location within the game window.- Returns:
- The location of the mouse on the current map.
- See Also:
getLocation()
getTile
java.awt.Point getTile()Gets the coordinates of the tile on the map on which the mouse is currently located at.- Returns:
- The tile on which the mouse is currently located at.
isGrabMouse
boolean isGrabMouse()A flag indicating whether the mouse should be grabbed by the game's window.- Returns:
- True if the mouse is locked to the game window; otherwise false.
isPressed
boolean isPressed()A flag indicating whether any mouse button is currently pressed.- Returns:
- True if any mouse button is currently pressed; otherwise false.
isLeftButtonPressed
boolean isLeftButtonPressed()A flag indicating whether the left mouse button is currently pressed.- Returns:
- True if the left mouse button is currently pressed; otherwise false.
isRightButtonPressed
boolean isRightButtonPressed()A flag indicating whether the right mouse button is currently pressed.- Returns:
- True if the right mouse button is currently pressed; otherwise false.
isLeftButton
boolean isLeftButton(java.awt.event.MouseEvent event)Returns true if the mouse event specifies the left mouse button.- Parameters:
event
- The MouseEvent object- Returns:
- true if the left mouse button was active.
isRightButton
boolean isRightButton(java.awt.event.MouseEvent event)Returns true if the mouse event specifies the right mouse button.- Parameters:
event
- The MouseEvent object- Returns:
- true if the right mouse button was active.
setGrabMouse
void setGrabMouse(boolean grab)If set to true, the mouse will be locked to the render component of the game.If this is set to true, the default cursor cannot be used anymore and instead a virtual cursor should be set.
- Parameters:
grab
- True if the mouse should be grabbed to the game's window, otherwise false.- See Also:
MouseCursor.set(java.awt.Image)
,GameWindow.cursor()
,Game.window()
setLocation
void setLocation(java.awt.geom.Point2D newLocation)Sets the current mouse location to the specified location in the game window.The location is not a location on the map but a location relative to the game window.
- Parameters:
newLocation
- The location to which the mouse will be moved.- See Also:
getLocation()
setLocation
void setLocation(double x, double y)Sets the current mouse location to the specified location in the game window.The location is not a location on the map but a location relative to the game window.
- Parameters:
x
- The x-coordinate to which the mouse will be moved.y
- The y-coordinate to which the mouse will be moved.- See Also:
getLocation()