MouseBehaviour

Many Behaviours are never interact with mouse presses, and if we checked every single Role when a mouse was pressed/released, this would be quite expensive (because to convert from screen coordinates to the Actor's local coordinates is non-trivial).

Therefore, when a mouse events, are only sent to Behaviours which also implement MouseBehaviour.

Properties

Link copied to clipboard

When set to false onMouseClicked will NOT be called. In some cases, you may want to keep this value true, even when the behaviour is inactive. For example, an inactive button may keep isMouseEnabled == true, and inside onMouseClicked play a sound to indicate the click did nothing. In such cases, the return value from onMouseClicked should be true, as the event has been handled.

Link copied to clipboard

Which implementation of Touching should be used for mouse events? The default is TouchingPixel.withinBoundsAndPixel.

Functions

Link copied to clipboard
open fun customProperties(): List<Property<*>>

Third party implementation of Role and Director can expose properties that can be edited in Kyd's editor.

Link copied to clipboard
open fun onActStarted(actor: Actor)
Link copied to clipboard
open fun onEnteredStage(actor: Actor)
Link copied to clipboard
open fun onExitedStage(actor: Actor, oldStage: Stage)
Link copied to clipboard
open fun onMouseClicked(actor: Actor, event: MouseEvent): Boolean

A mouse-click has occurred. touchTest has already returned true, so you can be sure that the click is near the Actor. Therefore, for a simple button, MouseEvent.local will be ignored. But for a slider we want to know how far along the slider; in which case we will only be concerned with the x component for a horizontal slider.

Link copied to clipboard
open fun onMouseDragged(actor: Actor, event: MouseEvent)

Only ever called when MouseEvent.capture is called in a previous onMousePressed event.

Link copied to clipboard
open fun onMousePressed(actor: Actor, event: MouseEvent): Boolean
Link copied to clipboard
open fun onMouseReleased(actor: Actor, event: MouseEvent)

Only ever called when MouseEvent.capture is called in a previous onMousePressed event.

Link copied to clipboard
open fun tick(actor: Actor, seconds: Float)