Class Mouse
java.lang.Object
de.gurkenlabs.litiengine.input.Mouse
- All Implemented Interfaces:
IMouse,IUpdateable,MouseListener,MouseMotionListener,MouseWheelListener,EventListener
public final class Mouse
extends Object
implements MouseListener, MouseMotionListener, MouseWheelListener, IMouse, IUpdateable
This implementation provides information about the mouse input in the LITIENGINE.
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.input.IMouse
IMouse.MouseClickedListener, IMouse.MouseDraggedListener, IMouse.MouseMovedListener, IMouse.MousePressedListener, IMouse.MousePressingListener, IMouse.MouseReleasedListener -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMouseListener(MouseListener listener) Register mouse listener.voidaddMouseMotionListener(MouseMotionListener listener) Register mouse motion listener.voidRemoves all registered event listeners from the Mouse instance.Gets the current location of the mouse within the game window.Gets the location of the mouse on the current map.getTile()Gets the coordinates of the tile on the map on which the mouse is currently located at.booleanA flag indicating whether the mouse should be grabbed by the game's window.booleanisLeftButton(MouseEvent event) Returns true if the mouse event specifies the left mouse button.booleanA flag indicating whether the left mouse button is currently pressed.booleanA flag indicating whether any mouse button is currently pressed.booleanisRightButton(MouseEvent event) Returns true if the mouse event specifies the right mouse button.booleanA flag indicating whether the right mouse button is currently pressed.voidvoidvoidvoidvoidvoidvoidvoidvoidonClicked(IMouse.MouseClickedListener listener) Adds the specified mouse clicked listener to receive events when the mouse has been clicked.voidonDragged(IMouse.MouseDraggedListener listener) Adds the specified mouse dragged listener to receive events when the mouse has been dragged.voidonMoved(IMouse.MouseMovedListener listener) Adds the specified mouse moved listener to receive events when the mouse has been moved.voidonPressed(IMouse.MousePressedListener listener) Adds the specified mouse pressed listener to receive events when the mouse has been pressed.voidonPressing(IMouse.MousePressingListener listener) Adds the specified mouse pressing listener to receive continuous events while the mouse is being pressed.voidonReleased(IMouse.MouseReleasedListener listener) Adds the specified mouse released listener to receive events when the mouse has been released.voidonWheelMoved(MouseWheelListener listener) Adds the specified mouse wheel listener to receive events when the mouse wheel has been moved.voidUnregisters the specified mouse clicked listener.voidUnregisters the specified mouse dragged listener.voidremoveMouseListener(MouseListener listener) Unregister mouse listener.voidremoveMouseMotionListener(MouseMotionListener listener) Unregister mouse motion listener.voidUnregisters the specified mouse moved listener.voidUnregisters the specified mouse pressed listener.voidUnregisters the specified mouse pressing listener.voidUnregisters the specified mouse released listener.voidremoveMouseWheelListener(MouseWheelListener listener) Unregisters the specified mouse wheel listener.voidsetGrabMouse(boolean grab) If set to true, the mouse will be locked to the render component of the game.voidsetLocation(double x, double y) Sets the current mouse location to the specified location in the game window.voidsetLocation(Point2D adjustMouse) Sets the current mouse location to the specified location in the game window.voidupdate()This method is called by the game loop on all objects that are attached to the loop.
-
Method Details
-
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
-
getLocation
Description copied from interface:IMouseGets 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.
UseIMouse.getMapLocation()to get a translated position for the current environment.- Specified by:
getLocationin interfaceIMouse- Returns:
- The current location of the mouse within the game window.
- See Also:
-
getMapLocation
Description copied from interface:IMouseGets 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.
UseIMouse.getLocation()to get the location within the game window.- Specified by:
getMapLocationin interfaceIMouse- Returns:
- The location of the mouse on the current map.
- See Also:
-
getTile
-
isGrabMouse
public boolean isGrabMouse()Description copied from interface:IMouseA flag indicating whether the mouse should be grabbed by the game's window.- Specified by:
isGrabMousein interfaceIMouse- Returns:
- True if the mouse is locked to the game window; otherwise false.
-
isLeftButtonPressed
public boolean isLeftButtonPressed()Description copied from interface:IMouseA flag indicating whether the left mouse button is currently pressed.- Specified by:
isLeftButtonPressedin interfaceIMouse- Returns:
- True if the left mouse button is currently pressed; otherwise false.
-
isPressed
-
isRightButtonPressed
public boolean isRightButtonPressed()Description copied from interface:IMouseA flag indicating whether the right mouse button is currently pressed.- Specified by:
isRightButtonPressedin interfaceIMouse- Returns:
- True if the right mouse button is currently pressed; otherwise false.
-
isLeftButton
Description copied from interface:IMouseReturns true if the mouse event specifies the left mouse button.- Specified by:
isLeftButtonin interfaceIMouse- Parameters:
event- The MouseEvent object- Returns:
- true if the left mouse button was active.
-
isRightButton
Description copied from interface:IMouseReturns true if the mouse event specifies the right mouse button.- Specified by:
isRightButtonin interfaceIMouse- Parameters:
event- The MouseEvent object- Returns:
- true if the right mouse button was active.
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
onClicked
Description copied from interface:IMouseAdds the specified mouse clicked listener to receive events when the mouse has been clicked. -
removeMouseClickedListener
Description copied from interface:IMouseUnregisters the specified mouse clicked listener.- Specified by:
removeMouseClickedListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
onDragged
Description copied from interface:IMouseAdds the specified mouse dragged listener to receive events when the mouse has been dragged. -
removeMouseDraggedListener
Description copied from interface:IMouseUnregisters the specified mouse dragged listener.- Specified by:
removeMouseDraggedListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
onMoved
Description copied from interface:IMouseAdds the specified mouse moved listener to receive events when the mouse has been moved. -
removeMouseMovedListener
Description copied from interface:IMouseUnregisters the specified mouse moved listener.- Specified by:
removeMouseMovedListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
onPressed
Description copied from interface:IMouseAdds the specified mouse pressed listener to receive events when the mouse has been pressed. -
removeMousePressedListener
Description copied from interface:IMouseUnregisters the specified mouse pressed listener.- Specified by:
removeMousePressedListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
onPressing
Description copied from interface:IMouseAdds the specified mouse pressing listener to receive continuous events while the mouse is being pressed.- Specified by:
onPressingin interfaceIMouse- Parameters:
listener- The listener to add.
-
removeMousePressingListener
Description copied from interface:IMouseUnregisters the specified mouse pressing listener.- Specified by:
removeMousePressingListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
onReleased
Description copied from interface:IMouseAdds the specified mouse released listener to receive events when the mouse has been released.- Specified by:
onReleasedin interfaceIMouse- Parameters:
listener- The listener to add.- See Also:
-
removeMouseReleasedListener
Description copied from interface:IMouseUnregisters the specified mouse released listener.- Specified by:
removeMouseReleasedListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
onWheelMoved
Description copied from interface:IMouseAdds the specified mouse wheel listener to receive events when the mouse wheel has been moved.- Specified by:
onWheelMovedin interfaceIMouse- Parameters:
listener- The listener to add.- See Also:
-
removeMouseWheelListener
Description copied from interface:IMouseUnregisters the specified mouse wheel listener.- Specified by:
removeMouseWheelListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
-
addMouseListener
Description copied from interface:IMouseRegister mouse listener.- Specified by:
addMouseListenerin interfaceIMouse- Parameters:
listener- the listener
-
removeMouseListener
Description copied from interface:IMouseUnregister mouse listener.- Specified by:
removeMouseListenerin interfaceIMouse- Parameters:
listener- the listener
-
addMouseMotionListener
Description copied from interface:IMouseRegister mouse motion listener.- Specified by:
addMouseMotionListenerin interfaceIMouse- Parameters:
listener- the listener
-
removeMouseMotionListener
Description copied from interface:IMouseUnregister mouse motion listener.- Specified by:
removeMouseMotionListenerin interfaceIMouse- Parameters:
listener- the listener
-
clearExplicitListeners
public void clearExplicitListeners()Description copied from interface:IMouseRemoves all registered event listeners from the Mouse instance. This does not affect registeredMouseListener,MouseMotionListenerorMouseWheelListenerinstances.- Specified by:
clearExplicitListenersin interfaceIMouse- See Also:
-
setGrabMouse
public void setGrabMouse(boolean grab) Description copied from interface:IMouseIf 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.
- Specified by:
setGrabMousein interfaceIMouse- Parameters:
grab- True if the mouse should be grabbed to the game's window, otherwise false.- See Also:
-
setLocation
Description copied from interface:IMouseSets 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.
- Specified by:
setLocationin interfaceIMouse- Parameters:
adjustMouse- The location to which the mouse will be moved.- See Also:
-
setLocation
public void setLocation(double x, double y) Description copied from interface:IMouseSets 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.
- Specified by:
setLocationin interfaceIMouse- 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:
-