britzldefold-input
britzl/defold-input/in.state
Cross-platform input handling for Defold: keyboard, mouse, gamepad, touch, and on-screen controls.
- GitHub: britzl/defold-input — pinned to
4.9.0- Pick a release from britzl/defold-input releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as state from "in.state"
- Pick a release from britzl/defold-input releases and add its Source code (zip) URL (or a packaged
Functions
create():StateInstanceacquire(url:Url, instance?:StateInstance)release(url:Url, instance?:StateInstance)is_pressed(action_id:Hash| string, instance?:StateInstance): booleanupdate(action_id:Hash| string, action: {}, instance?:StateInstance)on_input(action_id:Hash| string, action: {}, instance?:StateInstance)clear(instance?:StateInstance)
create(): StateInstanceU
Create an instance of the input state tracker
Returns
StateInstance— State instance
acquire(url: Url, instance?: StateInstance)U
Acquire input focus for the current script and clear state
Parameters
url:Urlinstance?:StateInstance— Optional state instance to modify. Will use global state instance if none is specified
release(url: Url, instance?: StateInstance)U
Release input focus for the current script and clear state
Parameters
url:Urlinstance?:StateInstance— Optional state instance to modify. Will use global state instance if none is specified
is_pressed(action_id: Hash | string, instance?: StateInstance): booleanU
Check if an action is pressed/active
Parameters
action_id:Hash | stringinstance?:StateInstance— Optional state instance to modify. Will use global state instance if none is specified
Returns
boolean— true if pressed/active
update(action_id: Hash | string, action: {}, instance?: StateInstance)U
Forward any calls to on_input from scripts using this module
Parameters
action_id:Hash | stringaction:{}instance?:StateInstance— Optional state instance to modify. Will use global state instance if none is specified
on_input(action_id: Hash | string, action: {}, instance?: StateInstance)
Parameters
action_id:Hash | stringaction:{}instance?:StateInstance
clear(instance?: StateInstance)U
Clear the state of any currently tracked input states
Parameters
instance?:StateInstance— Optional state instance to modify. Will use global state instance if none is specified