User Input

A Player can interact with both Entities and Scenes by using the keyboard or mouse. To enable this interaction the Scene or Entity should implement the appropriate interface, after which an event handler should be implemented.

Available interactions

The table below gives the full list of interfaces that are available. They can be found in package com.github.hanyaeger.api.userinput and most can be applied to all children of both YaegerEntity and YaegerScene, only the MouseDraggedListener can only be applied to children of YaegerEntity.

In case of a ScrollableDynamicScene, the instances of Coordinate2D that are passed to the event handlers report the coordinates of the entire scene, not only the viewport.

InterfaceEventHandler(s)
KeyListenervoid onPressedKeysChange(Set<KeyCode>)
MouseButtonPressedListenervoid onMouseButtonPressed(MouseButton, Coordinate2D)
MouseButtonReleasedListenervoid onMouseButtonReleased(MouseButton, Coordinate2D)
MouseEnterListenervoid onMouseEntered()
MouseExitListenervoid onMouseExited()
MouseMovedListenervoid onMouseMoved(Coordinate2D)
MouseMovedWhileDraggingListenervoid onMouseMovedWhileDragging(Coordinate2D)
MouseDraggedListenervoid onMouseDragged(Coordinate2D), void onDropped(Coordinate2D)
MouseDragEnterListenervoid onDragEntered(Coordinate2D, MouseDraggedListener)
MouseDragExitListenervoid onDragExited(Coordinate2D, MouseDraggedListener)
MouseDropListenervoid onDrop(Coordinate2D, MouseDraggedListener)