_InputManager
Extends:
A manager class intended to manage the javascript callback associated with the DOM. The InputManager filters general DOM events such as key down, key up, left and right click. The manager sorts events into referenceable lists for components to reference each game tick.
In result, the InputManager creates a bridge between the DOM and Engine. Components should use the
is
functions to determine if a specific character is down for that game tick.
If you want to listen to all characters, for example a textbox input, use events instead. To listen to events, use InputManager.events to access the event. Events are defined in InputManager.EVENT. See Messager.js for more info on listening to events.
Constructor Summary
Public Constructor | ||
public |
Constructor. |
Member Summary
Public Members | ||
public |
EVENT: {"LEFT_PRESSED": string, "LEFT_RELEASED": string, "RIGHT_PRESSED": string, "RIGHT_RELEASED": string, "MOUSE_MOVE": string, "KEY_DOWN": string, "KEY_UP": string, "KEY": string} |
|
public |
KEY_DOWN: *[] |
|
public |
KEY_PRESSED: *[] |
|
public |
KEY_UP: *[] |
|
public |
LEFT_PRESSED: *[] |
|
public |
LEFT_RELEASED: *[] |
|
public |
RIGHT_PRESSED: *[] |
|
public |
RIGHT_RELEASED: *[] |
|
public |
events: * |
Method Summary
Public Methods | ||
public |
Returns true if the key represented by this KeyCode is pressed down on this game tick. |
|
public |
isKeyPressed(KeyCode: KeyCode): boolean Returns true if the key represented by this KeyCode is held down on this game tick. |
|
public |
Returns true if the key represented by this KeyCode is released on this game tick. |
|
public |
start() Called by the EngineManager. |
|
public |
update() Managed by the EngineManager. |
Inherited Summary
From class Manager | ||
public |
end() |
|
public |
pause() |
|
public |
start() |
|
public |
unpause() |
|
public |
update() |
Public Constructors
public constructor() source
Constructor. Initializes Messager, event definitons, and key and mouse states.
Override:
Manager#constructorPublic Members
public EVENT: {"LEFT_PRESSED": string, "LEFT_RELEASED": string, "RIGHT_PRESSED": string, "RIGHT_RELEASED": string, "MOUSE_MOVE": string, "KEY_DOWN": string, "KEY_UP": string, "KEY": string} source
public KEY_DOWN: *[] source
public KEY_PRESSED: *[] source
public KEY_UP: *[] source
public LEFT_PRESSED: *[] source
public LEFT_RELEASED: *[] source
public RIGHT_PRESSED: *[] source
public RIGHT_RELEASED: *[] source
public events: * source
Public Methods
public isKeyDown(KeyCode: KeyCode): boolean source
Returns true if the key represented by this KeyCode is pressed down on
this game tick. Does not repeat each game tick. Must be released to re-trigger.
The isKeyPressed()
will also return true when this function does.
Params:
Name | Type | Attribute | Description |
KeyCode | KeyCode | Keycode enum which represents a character by number. |
public isKeyPressed(KeyCode: KeyCode): boolean source
Returns true if the key represented by this KeyCode is held down on this game tick. Repeats each game tick it is held down.
Params:
Name | Type | Attribute | Description |
KeyCode | KeyCode | Keycode enum which represents a character by number. |
public isKeyUp(KeyCode: KeyCode): boolean source
Returns true if the key represented by this KeyCode is released on this game tick.
Params:
Name | Type | Attribute | Description |
KeyCode | KeyCode | Keycode enum which represents a character by number. |
public start() source
Called by the EngineManager. Not intended to be referenced. Sets up event listeners on the DOM.
Override:
Manager#startpublic update() source
Managed by the EngineManager. Do not call directly. Updates character and mouse inputs.