Joystick

class Joystick(xAxisValue: () -> Float, yAxisValue: () -> Float, buttonValue: () -> Boolean, horizontalThreshold: Float = 0.0f, verticalThreshold: Float = 0.0f, reverseVertical: Boolean = true) : Control

A joystick has 2 JoystickAxis plus a button.

Parameters

xAxisValue

the value of the x-axis to watch

yAxisValue

the value of the y-axis to watch

buttonValue

the value of the button to watch

horizontalThreshold

the amount the horizontal axis has to be moved in either direction before it is considered 'displaced'

verticalThreshold

the amount the vertical axis has to be moved in either direction before it is considered 'displaced'

reverseVertical

by default, the y-axis of Joysticks are reversed (so pushing away from you decreases the value instead of increasing. When this is true, it will automatically correct for that.

Constructors

Link copied to clipboard
constructor(xAxisValue: () -> Float, yAxisValue: () -> Float, buttonValue: () -> Boolean, horizontalThreshold: Float = 0.0f, verticalThreshold: Float = 0.0f, reverseVertical: Boolean = true)

Properties

Link copied to clipboard

The Button of the joystick.

Link copied to clipboard

This command will be scheduled every time the joystick moves off center. Note that it receives a pair of floats; these are the x and y values.

Link copied to clipboard

Whether the current boolean state just changed to false.

Link copied to clipboard

This command will be scheduled every update that the joystick isn't centered. Note that it receives a pair of floats; these are the x and y values.

Link copied to clipboard

Current profile curve (defaults to linear)

Link copied to clipboard

This command will be scheduled every time the joystick returns to center. Note that it receives a pair of floats; these are the x and y values.

Link copied to clipboard

Whether the current boolean state just changed to true.

Link copied to clipboard

The current boolean state of this control.

Link copied to clipboard

This command will be scheduled whenever the state changes. Note that it receives a pair of floats; these are the x and y values.

Link copied to clipboard

Whether the current boolean state just changed.

Link copied to clipboard
val x: Float

X-value of the joystick.

Link copied to clipboard

The JoystickAxis representing horizontal motion.

Link copied to clipboard
val y: Float

Y-value of the joystick. If reverseVertical is true, this will be the corrected direction.

Link copied to clipboard

The JoystickAxis representing vertical motion.

Functions

Link copied to clipboard
open override fun update()

Updates the current state and the rising, falling, and changed states. Further, schedules commands accordingly.