Class: WASDController

Grape2D. WASDController

new WASDController(renderer)

An WASD controller is a top-level way to control input. This allows for a easier way to capture W, A, S, D keys. This is mostly used to control movement, so with that in mind, the keys pairs W and S can't have the same state at the same time, the same goes for the pair A and D. However it possible to have W with the same state as either A or D, but not both. Again, the same goes for S. If a key it's press, lets say W, and it's opposite is also pressed, in this case S, the controller keeps the state that indicated that W is pressed. But when the key W is lifted up (key up event), the controller waits for the next event, and S is not automatically press (for the controller).
Parameters:
Name Type Description
renderer Grape2D.Renderer Renderer to bind the events.
Source:

Members

<private> aLock :boolean

'A' key is locked/pressed.
Type:
  • boolean
Source:

<private> dLock :boolean

'D' key is locked/pressed.
Type:
  • boolean
Source:

<private> im :Grape2D.InputManager

Input manager.
Type:
Source:

<private> sLock :boolean

'S' key is locked/pressed.
Type:
  • boolean
Source:

<private> wLock :boolean

'W' key is locked/pressed.
Type:
  • boolean
Source:

Methods

a()

Action for the 'A' key.
Source:

aUp()

Action for when the 'A' keys is released.
Source:

d()

Action for the 'D' key.
Source:

dUp()

Action for when the 'D' keys is released.
Source:

isA() → {boolean}

Checks if the key 'A' is pressed.
Source:
Returns:
True if it's pressed.
Type
boolean

isD() → {boolean}

Checks if the key 'D' is pressed.
Source:
Returns:
True if it's pressed.
Type
boolean

isS() → {boolean}

Checks if the key 'S' is pressed.
Source:
Returns:
True if it's pressed.
Type
boolean

isW() → {boolean}

Checks if the key 'W' is pressed.
Source:
Returns:
True if it's pressed.
Type
boolean

s()

Action for the 'S' key.
Source:

sUp()

Action for when the 'S' keys is released.
Source:

w()

Action for the 'W' key.
Source:

wUp()

Action for when the 'W' keys is released.
Source: