public interface IMouse
IMouse
interface is the engine's API for receiving mouse input events.Modifier and Type | Interface and 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.
|
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 |
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.
|
void onClicked(IMouse.MouseClickedListener listener)
listener
- The listener to add.MouseListener.mouseClicked(MouseEvent)
,
MouseEvent.MOUSE_CLICKED
void removeMouseClickedListener(IMouse.MouseClickedListener listener)
listener
- The listener to remove.void onDragged(IMouse.MouseDraggedListener listener)
listener
- The listener to add.IMouse.MouseDraggedListener.mouseDragged(MouseEvent)
,
MouseMotionListener.mouseDragged(MouseEvent)
,
MouseEvent.MOUSE_DRAGGED
void removeMouseDraggedListener(IMouse.MouseDraggedListener listener)
listener
- The listener to remove.void onMoved(IMouse.MouseMovedListener listener)
listener
- The listener to add.MouseMotionListener.mouseMoved(MouseEvent)
,
MouseEvent.MOUSE_MOVED
void removeMouseMovedListener(IMouse.MouseMovedListener listener)
listener
- The listener to remove.void onPressed(IMouse.MousePressedListener listener)
listener
- The listener to add.MouseListener.mousePressed(MouseEvent)
,
MouseEvent.MOUSE_PRESSED
void removeMousePressedListener(IMouse.MousePressedListener listener)
listener
- The listener to remove.void onPressing(IMouse.MousePressingListener listener)
listener
- The listener to add.void removeMousePressingListener(IMouse.MousePressingListener listener)
listener
- The listener to remove.void onReleased(IMouse.MouseReleasedListener listener)
listener
- The listener to add.MouseListener.mouseReleased(MouseEvent)
,
MouseEvent.MOUSE_RELEASED
void removeMouseReleasedListener(IMouse.MouseReleasedListener listener)
listener
- The listener to remove.void onWheelMoved(java.awt.event.MouseWheelListener listener)
listener
- The listener to add.MouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)
,
MouseWheelEvent
void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)
listener
- The listener to remove.void addMouseListener(java.awt.event.MouseListener listener)
listener
- the listenervoid removeMouseListener(java.awt.event.MouseListener listener)
listener
- the listenervoid addMouseMotionListener(java.awt.event.MouseMotionListener listener)
listener
- the listenervoid removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
listener
- the listenervoid clearExplicitListeners()
MouseListener
,
MouseMotionListener
or MouseWheelListener
instances.java.awt.geom.Point2D getLocation()
The coordinates are relative to the game window and don't reflect coordinates on the game world.
Use getMapLocation()
to get a translated position for the current environment.
getMapLocation()
java.awt.geom.Point2D getMapLocation()
This translates the current mouse locations to the location on the map by using the current camera.
Use getLocation()
to get the location within the game window.
getLocation()
java.awt.Point getTile()
boolean isGrabMouse()
boolean isPressed()
boolean isLeftButtonPressed()
boolean isRightButtonPressed()
void setGrabMouse(boolean grab)
If this is set to true, the default cursor cannot be used anymore and instead a virtual cursor should be set.
grab
- True if the mouse should be grabbed to the game's window, otherwise false.MouseCursor.set(java.awt.Image)
,
GameWindow.cursor()
,
Game.window()
void setLocation(java.awt.geom.Point2D newLocation)
The location is not a location on the map but a location relative to the game window.
newLocation
- The location to which the mouse will be moved.getLocation()
void setLocation(double x, double y)
The location is not a location on the map but a location relative to the game window.
x
- The x-coordinate to which the mouse will be moved.y
- The y-coordinate to which the mouse will be moved.getLocation()