Inputs
client-side
Keyboard InputsTIP
- Must be used inside update loop
- Uses javascript keycodes: https://keycode.info/
WARNING
GAME.INPUTS.keyDown seems to be broken currently
# Do something when "c" (key code 67) is held down
public action update(num delta) {
if (GAME.INPUTS.keyDown(67)) {
# do something
};
}
1
2
3
4
5
6
2
3
4
5
6
client-side
Mouse PositionWARNING
GAME.INPUTS.mousePos() does not work currently
# Get mouse position
obj mousePosition = GAME.INPUTS.mousePos();
# Draw a red circle at the position of the mouse
GAME.OVERLAY.drawCircle((num) mousePosition.x, (num) mousePosition.y, 10, 10, 0, "#ff0000");
1
2
3
4
5
2
3
4
5
client-side
Mouse Movement# Get mouse movement vector
obj pos = GAME.INPUTS.mouseMovement();
1
2
2
client-side
Unlock Mouse# Unlock mouse
GAME.INPUTS.unlockMouse();
# Unlock mouse entirely, unfocussing the window
GAME.INPUTS.freeMouse();
1
2
3
4
5
2
3
4
5
client-side
Input Listeners# Mouse click
public action onMouseClick(num button, num x, num y) {
# num button - mouse click button id (1: left mouse, 2: middle mouse, 3: right mouse, 4+: mouse macro's)
# num x - x position of mouse
# num y - y position of mouse
}
1
2
3
4
5
6
2
3
4
5
6
# After mouse click
public action onMouseUp(num button, num x, num y) {
# num button - mouse click button id (1: left mouse, 2: middle mouse, 3: right mouse, 4+: mouse macro's)
# num x - x position of mouse
# num y - y position of mouse
}
1
2
3
4
5
6
2
3
4
5
6
# When mouse scrolls
public action onMouseScroll(num dir) {
# num dir - 1: scroll up, scroll left 2: scroll down, scroll right
}
1
2
3
4
2
3
4
# When key is being pressed
public action onKeyPress(str key, num code) {
# str key - key in text format. (space == " ")
# num code - code of key. (space == 32)
}
1
2
3
4
5
2
3
4
5
# After key was pressed
public action onKeyUp(str key, num code) {
# str key - key in text format. (space == " ")
# num code - code of key. (space == 32)
}
1
2
3
4
5
2
3
4
5
# When key is held
public action onKeyHeld(str key, num code) {
# str key - key in text format. (space == " ")
# num code - code of key. (space == 32)
}
1
2
3
4
5
2
3
4
5
client-side
Controller input listenersWARNING
- Input hooks have a very inconsistent
code
parameter, its recommended to use thekey
parameter instead
# Runs when a controller button gets pressed
public action onControllerPress(str key, num code) {
#str key - button in text format (dpad up == "dpad_up")
#num code - code of button (shoulder_bottom_left == 10003)
}
1
2
3
4
5
2
3
4
5
# Runs when a controller button was pressed
public action onControllerUp(str key, num code) {
#str key - button in text format (dpad up == "dpad_up")
#num code - code of button (shoulder_bottom_left == 10003)
}
1
2
3
4
5
2
3
4
5
# Runs when a controller button is being held
public action onControllerHeld(str key, num code) {
#str key - button in text format (dpad up == "dpad_up")
#num code - code of button (shoulder_bottom_left == 10003)
}
1
2
3
4
5
2
3
4
5