@input
This class has storage for the states of the keys of the keyboard, the mouse and gamepads.
This class has storage for the states of the keys of the keyboard, the mouse and gamepads.
var gamepad: input.getGamepad();
if input.getMousePressed() {
someObj.setX(input.getMouseX());
someObj.setY(input.getMouseY());
}
Type: var.[65536 x bool]
Storage for the press status of each key on the keyboard.
@self.keyStates[keyCode]: value;
Type: var.[8 x @gamepad]
Storage for the states of the gamepads.
@self.gamepads[gamepadId].buttonStates[buttonId]: value;
Type: var.i64
The amount of gamepads that are currently in use.
input.gamepadCount +: 1;
Type: var.[8 x @mouseState]
Storage for the button states and location of the mouse.
input.mouseStates[buttonNumber]: @mouseState {
x: x;
y: y;
pressed: true;
};
Type: fn(i16) => bool
Returns wether the key with the given code is pressed.
The number identifying which key.
if input.isKeyDown(KeyBoard.enter) {
print "key down";
}
Type: fn(i16,bool)
Sets the press status of the key on the keyboard with the given keyCode.
The number identifying which key.
Wether it is pressed or not.
inut.setKeyDown(keyCode, value);
Type: fn(i64) => @gamepad
Returns the gamepad object for the given gamepadId.
The number identifying the gamepad. Defaults to 0.
//get the first gamepad
var gamepad: input.getGamepad();
//get the second one
var gamepad2: input.getGamepad(1);
Type: fn(i64,i64) => bool
Returns the gamepad object for the given gamepadId.
The number identifying the gamepad.
The number identifying the button of the gamepad.
if input.isGamepadButtonDown(0, 3) {
//etc
}
Type: fn(i64,i64,bool)
Sets the press state of the button with given buttonId on the gamepad with given gamepadId.
The number identifying the gamepad.
The number identifying the button of the gamepad.
Wether or not it is pressed.
input.setGamepadButtonDown(gamepadId: 0; buttonId: 1; value: true);
Type: fn(i64,f64)
Sets the position of the thumbstick in the horizontal axis for the gamepad with given gamepadId.
The number identifying the gamepad.
The number representing the x amount. Valid values are between 0.0 and 1.0;
input.setGamepadX(0, 0.5);
Type: fn(i64,f64)
Sets the position of the thumbstick in the vertical axis for the gamepad with given gamepadId.
The number identifying the gamepad.
The number representing the y amount. Valid values are between 0.0 and 1.0;
input.setGamepadY(0, 1.0);
Type: fn(i64,f64)
Sets the position of the second thumbstick in the horizontal axis for the gamepad with given gamepadId.
The number identifying the gamepad.
The number representing the x amount. Valid values are between 0.0 and 1.0;
input.setGamepadX2(0, 0);
Type: fn(i64,f64)
Sets the position of the second thumbstick in the vertical axis for the gamepad with given gamepadId.
The number identifying the gamepad.
The number representing the y amount. Valid values are between 0.0 and 1.0;
input.setGamepadY2(0, 0);
Type: fn(i64) => f64
Returns the location on the horizontal axis of the mouse cursor, in window coordinates.
The button number. Defaults to 0. The x and y coordinates of the mouse cursor are stored at index 0.
print input.getMouseX();
Type: fn(i64) => f64
Returns the location on the vertical axis of the mouse cursor, in window coordinates.
The button number. Defaults to 0. The x and y coordinates of the mouse cursor are stored at index 0.
print input.getMouseY();
Type: fn(i64) => bool
Returns the press state of the button with given numnber of the mouse.
The button number.
if getMousePressed(0) {
//etc
}
Type: fn(i64,f64,f64)
Sets the x and y coordinates for the mouse. Use window coordinates.
The button number. Defaults to 0. The x and y coordinates of the mouse cursor are stored at index 0.
The number representing the x coordinate.
The number representing the y coordinate.
To gain a better understanding of this class, it is recommended to look at the source code of the following file: