Io
const io = require("@vectarine/io")Functions
Section titled “Functions”io.isKeyDown
Section titled “io.isKeyDown”io.isKeyDown(keycode: Scancode | string): booleanChecks if a key is pressed
For example, IsKeyDown("Space"). If the name is invalid, always return false.
You can use ‘GetKeysDown’ to find the name of keys
io.getKeyName
Section titled “io.getKeyName”io.getKeyName(keycode: Scancode | string): stringGet the name of a key. For example getKeyName(“Z”) returns “W” on AZERTY but “Z” on QWERTY. This is the name you should show the player when telling them to press a key. Returns nil if the scancode is invalid.
io.getTextInput
Section titled “io.getTextInput”io.getTextInput(): stringGet the text inputed since the last frame. This should be used for typing text, while IsKeyDown should be used for checking if a key is pressed for actions.
io.isKeyJustPressed
Section titled “io.isKeyJustPressed”io.isKeyJustPressed(keycode: Scancode | string): booleanChecks if a key was just pressed (this frame)
The keys are independent from the keyboard layout, so “Q” is always the top-left letter, even on AZERTY layouts.
This is the function you need to map button presses to actions, but not for typing text.
For example, IsKeyJustPressed("space"). If the name is invalid, always return false.
You can use ‘GetKeysDown’ to find the name of keys
io.getKeysDown
Section titled “io.getKeysDown”io.getKeysDown(): { Scancode }Returns a list of key that are currently pressed
io.getMouse
Section titled “io.getMouse”io.getMouse(): Vec.Vec2Get the current mouse position in OpenGL coordinates
io.getMouseState
Section titled “io.getMouseState”io.getMouseState(): {Get the current mouse state
io.getMouseWheel
Section titled “io.getMouseWheel”io.getMouseWheel(): Vec.Vec2Get how much the mouse wheel has been scrolled since the last frame. The x value is for horizontal scrolling, and the y value is for vertical scrolling. This is because some mice have horizontal scroll (but i’ve never seen one in real life). On most mice, the x value will always be 0.
io.getCurrentTouches
Section titled “io.getCurrentTouches”io.getCurrentTouches(): { Touch }Get all fingers that are currently touching the screen.
io.getWindowSize
Section titled “io.getWindowSize”io.getWindowSize(): Vec.Vec2Get the current window size (in px)
io.centerWindow
Section titled “io.centerWindow”io.centerWindow(): ()Center the window on the screen Does nothing on the web
io.getScreenSize
Section titled “io.getScreenSize”io.getScreenSize(): Vec.Vec2Get the current screen size (in px)
io.setWindowSize
Section titled “io.setWindowSize”io.setWindowSize(width: number, height: number): ()Sets the window size. On the web and in the editor, this adds black borders to make the window match the requested aspect ratio. On desktop, this will resize the window to the requested size.
io.setResizeable
Section titled “io.setResizeable”io.setResizeable(resizeable: boolean): ()Set if the window is resizeable
io.setWindowTitle
Section titled “io.setWindowTitle”io.setWindowTitle(title: string): ()Set the window title
io.isWindowMinimized
Section titled “io.isWindowMinimized”io.isWindowMinimized(): booleanReturns true if the window is currently minimized When this is the case, Vectarine will run a lot slower to save battery life and avoid draining the CPU.
io.setFullscreen
Section titled “io.setFullscreen”io.setFullscreen(fullscreen: true | false | "fullscreen" | "windowed" | "desktop"): ()Set the window to fullscreen, windowed, or “desktop fullscreen” (also called fake fullscreen) mode true means “fullscreen”, false means “windowed”. Before calling this function, you can set the window size to the size of the screen to avoid black borders. On the web, the game is usually embedded in an iframe / player which already provides a fullscreen button, so this function does nothing.
Scancode
Section titled “Scancode”export type Scancode = ...List of all available scancodes. A scancode is a location on the keyboard, independent of keyboard layout.
export type Touch = ...Touch.id
Section titled “Touch.id”id: numberA stable identifier for this finger while it remains on the screen.
Touch.position
Section titled “Touch.position”position: Vec.Vec2The current position in OpenGL coordinates.
Touch.pressure
Section titled “Touch.pressure”pressure: numberThe normalized pressure reported by the device.
