public final class Mouse extends java.lang.Object implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, IMouse, IUpdateable
IMouse.MouseClickedListener, IMouse.MouseDraggedListener, IMouse.MouseMovedListener, IMouse.MousePressedListener, IMouse.MousePressingListener, IMouse.MouseReleasedListener
Modifier and Type | Method and 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 |
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 |
isRightButtonPressed()
A flag indicating whether the right mouse button is currently pressed.
|
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e) |
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 adjustMouse)
Sets the current mouse location to the specified location in the game window.
|
void |
update()
This method is called by the game loop on all objects that are attached to the loop.
|
public void update()
IUpdateable
ClientConfiguration
.update
in interface IUpdateable
ClientConfiguration.setMaxFps(int)
public java.awt.geom.Point2D getLocation()
IMouse
The coordinates are relative to the game window and don't reflect coordinates on the game world.
Use IMouse.getMapLocation()
to get a translated position for the current environment.
getLocation
in interface IMouse
IMouse.getMapLocation()
public java.awt.geom.Point2D getMapLocation()
IMouse
This translates the current mouse locations to the location on the map by using the current camera.
Use IMouse.getLocation()
to get the location within the game window.
getMapLocation
in interface IMouse
IMouse.getLocation()
public java.awt.Point getTile()
IMouse
public boolean isGrabMouse()
IMouse
isGrabMouse
in interface IMouse
public boolean isLeftButtonPressed()
IMouse
isLeftButtonPressed
in interface IMouse
public boolean isPressed()
IMouse
public boolean isRightButtonPressed()
IMouse
isRightButtonPressed
in interface IMouse
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
public void onClicked(IMouse.MouseClickedListener listener)
IMouse
public void removeMouseClickedListener(IMouse.MouseClickedListener listener)
IMouse
removeMouseClickedListener
in interface IMouse
listener
- The listener to remove.public void onDragged(IMouse.MouseDraggedListener listener)
IMouse
onDragged
in interface IMouse
listener
- The listener to add.IMouse.MouseDraggedListener.mouseDragged(MouseEvent)
,
MouseMotionListener.mouseDragged(MouseEvent)
,
MouseEvent.MOUSE_DRAGGED
public void removeMouseDraggedListener(IMouse.MouseDraggedListener listener)
IMouse
removeMouseDraggedListener
in interface IMouse
listener
- The listener to remove.public void onMoved(IMouse.MouseMovedListener listener)
IMouse
public void removeMouseMovedListener(IMouse.MouseMovedListener listener)
IMouse
removeMouseMovedListener
in interface IMouse
listener
- The listener to remove.public void onPressed(IMouse.MousePressedListener listener)
IMouse
public void removeMousePressedListener(IMouse.MousePressedListener listener)
IMouse
removeMousePressedListener
in interface IMouse
listener
- The listener to remove.public void onPressing(IMouse.MousePressingListener listener)
IMouse
onPressing
in interface IMouse
listener
- The listener to add.public void removeMousePressingListener(IMouse.MousePressingListener listener)
IMouse
removeMousePressingListener
in interface IMouse
listener
- The listener to remove.public void onReleased(IMouse.MouseReleasedListener listener)
IMouse
onReleased
in interface IMouse
listener
- The listener to add.MouseListener.mouseReleased(MouseEvent)
,
MouseEvent.MOUSE_RELEASED
public void removeMouseReleasedListener(IMouse.MouseReleasedListener listener)
IMouse
removeMouseReleasedListener
in interface IMouse
listener
- The listener to remove.public void onWheelMoved(java.awt.event.MouseWheelListener listener)
IMouse
onWheelMoved
in interface IMouse
listener
- The listener to add.MouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)
,
MouseWheelEvent
public void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)
IMouse
removeMouseWheelListener
in interface IMouse
listener
- The listener to remove.public void addMouseListener(java.awt.event.MouseListener listener)
IMouse
addMouseListener
in interface IMouse
listener
- the listenerpublic void removeMouseListener(java.awt.event.MouseListener listener)
IMouse
removeMouseListener
in interface IMouse
listener
- the listenerpublic void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
IMouse
addMouseMotionListener
in interface IMouse
listener
- the listenerpublic void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
IMouse
removeMouseMotionListener
in interface IMouse
listener
- the listenerpublic void clearExplicitListeners()
IMouse
MouseListener
,
MouseMotionListener
or MouseWheelListener
instances.clearExplicitListeners
in interface IMouse
IMouse.onClicked(MouseClickedListener)
,
IMouse.onDragged(MouseDraggedListener)
,
IMouse.onMoved(MouseMovedListener)
,
IMouse.onPressed(MousePressedListener)
,
IMouse.onPressing(MousePressingListener)
,
IMouse.onReleased(MouseReleasedListener)
public void setGrabMouse(boolean grab)
IMouse
If this is set to true, the default cursor cannot be used anymore and instead a virtual cursor should be set.
setGrabMouse
in interface IMouse
grab
- True if the mouse should be grabbed to the game's window, otherwise false.MouseCursor.set(java.awt.Image)
,
GameWindow.cursor()
,
Game.window()
public void setLocation(java.awt.geom.Point2D adjustMouse)
IMouse
The location is not a location on the map but a location relative to the game window.
setLocation
in interface IMouse
adjustMouse
- The location to which the mouse will be moved.IMouse.getLocation()
public void setLocation(double x, double y)
IMouse
The location is not a location on the map but a location relative to the game window.
setLocation
in interface IMouse
x
- The x-coordinate to which the mouse will be moved.y
- The y-coordinate to which the mouse will be moved.IMouse.getLocation()