Input
Actions
Section titled “Actions”An action is a name bound to keys and gamepad buttons, defined in Project settings.
| Function | What it does |
|---|---|
held(action) |
The action is held. |
pressed(action) |
The action was pressed on this step. |
released(action) |
The action was released on this step. |
axis(negative, positive) |
From -1 to 1: the positive action minus the negative. The stick has a 0.25 dead zone. |
self.hspeed = axis("esquerda", "direita") * 2if pressed("pular") then self.vspeed = -4 endhspeed = axis("esquerda", "direita") * 2;if (pressed("pular")) vspeed = -4;Keyboard
Section titled “Keyboard”held, pressed and released also accept a key.
if pressed(Key.Escape) then quit() endif (pressed(Key::Escape)) quit();| Group | Keys |
|---|---|
| Letters | A … Z |
| Numbers | Num0 … Num9 |
| Arrows | Left, Right, Up, Down |
| Special | Space, Enter, Escape, Tab, Backspace |
| Modifiers | LShift, RShift, LCtrl, RCtrl |
| Function | F1 … F12 |
| Function | What it does |
|---|---|
mouseX(), mouseY() |
Mouse position in the world (accounts for the camera). |
mouseGuiX(), mouseGuiY() |
Mouse position on screen, for onRenderGui. |
mouseHeld(button) |
The button is held. |
mousePressed(button) |
The button was pressed on this step. |
mouseReleased(button) |
The button was released on this step. |
mouseWheel() |
How much the wheel turned on this step: positive is up. |
if mousePressed(Mouse.Left) then self:setDirection(self:angleTo(mouseX(), mouseY()))endif (mousePressed(MouseButton::Left)) setDirection(angleTo(mouseX(), mouseY()));Buttons: Left, Middle, Right. In C++, mouseGuiX, mouseGuiY and mouseWheel are under Input::.
Gamepad
Section titled “Gamepad”The gamepad is read through actions. The first connected gamepad is used. Names used in Project settings:
| Group | Names |
|---|---|
| Buttons | Pad:A, Pad:B, Pad:X, Pad:Y, Pad:Start, Pad:Back, Pad:LB, Pad:RB |
| D-pad | Pad:Up, Pad:Down, Pad:Left, Pad:Right |
| Left stick | Pad:LeftX-, Pad:LeftX+, Pad:LeftY-, Pad:LeftY+ |
