Package de.gurkenlabs.litiengine.input
Class Mouse
java.lang.Object
de.gurkenlabs.litiengine.input.Mouse
- All Implemented Interfaces:
IMouse,IUpdateable,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.event.MouseWheelListener,java.util.EventListener
public final class Mouse
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, IMouse, IUpdateableThis 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.MouseReleasedListenerMethod Summary
Modifier and Type Method Description voidaddMouseListener(java.awt.event.MouseListener listener)Register mouse listener.voidaddMouseMotionListener(java.awt.event.MouseMotionListener listener)Register mouse motion listener.voidclearExplicitListeners()Removes all registered event listeners from the Mouse instance.java.awt.geom.Point2DgetLocation()Gets the current location of the mouse within the game window.java.awt.geom.Point2DgetMapLocation()Gets the location of the mouse on the current map.java.awt.PointgetTile()Gets the coordinates of the tile on the map on which the mouse is currently located at.booleanisGrabMouse()A flag indicating whether the mouse should be grabbed by the game's window.booleanisLeftButton(java.awt.event.MouseEvent event)Returns true if the mouse event specifies the left mouse button.booleanisLeftButtonPressed()A flag indicating whether the left mouse button is currently pressed.booleanisPressed()A flag indicating whether any mouse button is currently pressed.booleanisRightButton(java.awt.event.MouseEvent event)Returns true if the mouse event specifies the right mouse button.booleanisRightButtonPressed()A flag indicating whether the right mouse button is currently pressed.voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)voidmouseWheelMoved(java.awt.event.MouseWheelEvent e)voidonClicked(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(java.awt.event.MouseWheelListener listener)Adds the specified mouse wheel listener to receive events when the mouse wheel has been moved.voidremoveMouseClickedListener(IMouse.MouseClickedListener listener)Unregisters the specified mouse clicked listener.voidremoveMouseDraggedListener(IMouse.MouseDraggedListener listener)Unregisters the specified mouse dragged listener.voidremoveMouseListener(java.awt.event.MouseListener listener)Unregister mouse listener.voidremoveMouseMotionListener(java.awt.event.MouseMotionListener listener)Unregister mouse motion listener.voidremoveMouseMovedListener(IMouse.MouseMovedListener listener)Unregisters the specified mouse moved listener.voidremoveMousePressedListener(IMouse.MousePressedListener listener)Unregisters the specified mouse pressed listener.voidremoveMousePressingListener(IMouse.MousePressingListener listener)Unregisters the specified mouse pressing listener.voidremoveMouseReleasedListener(IMouse.MouseReleasedListener listener)Unregisters the specified mouse released listener.voidremoveMouseWheelListener(java.awt.event.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(java.awt.geom.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:
ClientConfiguration.setMaxFps(int)
getLocation
public java.awt.geom.Point2D 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:
IMouse.getMapLocation()
getMapLocation
public java.awt.geom.Point2D 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:
IMouse.getLocation()
getTile
public java.awt.Point getTile()Description copied from interface:IMouseGets the coordinates of the tile on the map on which the mouse is currently located at.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
public boolean isPressed()Description copied from interface:IMouseA flag indicating whether any mouse button is currently pressed.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
public boolean isLeftButton(java.awt.event.MouseEvent event)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
public boolean isRightButton(java.awt.event.MouseEvent event)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
public void mouseClicked(java.awt.event.MouseEvent e)- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)- Specified by:
mouseWheelMovedin interfacejava.awt.event.MouseWheelListener
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.- Specified by:
onDraggedin interfaceIMouse- Parameters:
listener- The listener to add.- See Also:
IMouse.MouseDraggedListener.mouseDragged(MouseEvent),MouseMotionListener.mouseDragged(MouseEvent),MouseEvent.MOUSE_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:
MouseListener.mouseReleased(MouseEvent),MouseEvent.MOUSE_RELEASED
removeMouseReleasedListener
Description copied from interface:IMouseUnregisters the specified mouse released listener.- Specified by:
removeMouseReleasedListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
onWheelMoved
public void onWheelMoved(java.awt.event.MouseWheelListener listener)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:
MouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent),MouseWheelEvent
removeMouseWheelListener
public void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)Description copied from interface:IMouseUnregisters the specified mouse wheel listener.- Specified by:
removeMouseWheelListenerin interfaceIMouse- Parameters:
listener- The listener to remove.
addMouseListener
public void addMouseListener(java.awt.event.MouseListener listener)Description copied from interface:IMouseRegister mouse listener.- Specified by:
addMouseListenerin interfaceIMouse- Parameters:
listener- the listener
removeMouseListener
public void removeMouseListener(java.awt.event.MouseListener listener)Description copied from interface:IMouseUnregister mouse listener.- Specified by:
removeMouseListenerin interfaceIMouse- Parameters:
listener- the listener
addMouseMotionListener
public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)Description copied from interface:IMouseRegister mouse motion listener.- Specified by:
addMouseMotionListenerin interfaceIMouse- Parameters:
listener- the listener
removeMouseMotionListener
public void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)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:
IMouse.onClicked(MouseClickedListener),IMouse.onDragged(MouseDraggedListener),IMouse.onMoved(MouseMovedListener),IMouse.onPressed(MousePressedListener),IMouse.onPressing(MousePressingListener),IMouse.onReleased(MouseReleasedListener)
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:
MouseCursor.set(java.awt.Image),GameWindow.cursor(),Game.window()
setLocation
public void setLocation(java.awt.geom.Point2D adjustMouse)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:
IMouse.getLocation()
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:
IMouse.getLocation()
