InputControllers.DirectionalInputController

Description: Defines a DirectionalInputController that will monitor Up, Right, Left, and Down movement attempts.

Constructors

DirectionalInputController (keyboard, onMove)
Creates a new instance of the DirectionalInputController object with default key controls.

keyboard: EndGate.Input.KeyboardHandler
A keyboard handler in order to bind directional events.

onMove: (direction: string, startMoving: boolean) => void
The function to trigger when the user attempts to perform a move. Passes the direction ("Left", "Right", "Up", "Down") and whether the movement was started or stopped.

DirectionalInputController (keyboard, onMove, upKeys, rightKeys, downKeys, leftKeys)
Creates a new instance of the DirectionalInputController object with custom key controls.

keyboard: EndGate.Input.KeyboardHandler
A keyboard handler in order to bind directional events.

onMove: (direction: string, startMoving: boolean) => void
The function to trigger when the user attempts to perform a move. Passes the direction ("Left", "Right", "Up", "Down") and whether the movement was started or stopped.

upKeys: string[]
Array of keys to trigger an "Up" movement. Default is ["w", "Up"].

rightKeys: string[]
Array of keys to trigger a "Right" movement. Default is ["d", "Right"].

downKeys: string[]
Array of keys to trigger a "Down" movement. Default is ["s", "Down"].

leftKeys: string[]
Array of keys to trigger a "Left" movement. Default is ["a", "Left"].

Examples

There's currently no example available for this page. If you'd like to suggest one send me an containing a description, code, and link to the page for the suggested example. As a thanks I'll associate the code snippet with your name directly below the example if approved.