new InputManager()
Central hub for input. Manages keyboard and mouse sub-modules,
and handles abstract input actions mapped to physical keys.
Call `initialize(canvas)` once, then `update()` once per game frame.
- Source:
Methods
defineAction(actionName, bindings)
Defines an action and maps it to one or more input bindings.
Parameters:
Name | Type | Description |
---|---|---|
actionName |
string | The unique name for the action (e.g., "moveUp", "fire"). |
bindings |
Array.<InputBinding> | An array of binding objects. |
- Source:
destroy()
Cleans up event listeners and all input states from sub-modules.
- Source:
getActionValue(actionName) → {number}
Gets the analog value of an action (e.g., from an axis or trigger).
Typically ranges from 0 to 1.
Parameters:
Name | Type | Description |
---|---|---|
actionName |
string | The name of the action. |
- Source:
Returns:
- Type
- number
initialize(canvasElement, engine)
Initializes the InputManager and its sub-modules (Keyboard, Mouse, Gamepad).
Parameters:
Name | Type | Default | Description |
---|---|---|---|
canvasElement |
HTMLCanvasElement | The game canvas element (required for Mouse). | |
engine |
null |
- Source:
update()
Updates all input modules and polls all bindings to update action states.
Should be called once per game loop frame by the engine.
- Source: