Move an entity in four directions by using the
arrow keys or W
, A
, S
, D
.
public this .fourway(Number speed)
Constructor to initialize the speed. Component will listen for key events and move the entity appropriately.
This includes Up Arrow
, Right Arrow
, Down Arrow
, Left Arrow
as well as W
, A
, S
, D
.
When direction changes a NewDirection event is triggered with an object detailing the new direction: {x: x_movement, y: y_movement} When entity has moved on either x- or y-axis a Moved event is triggered with an object specifying the old position {x: old_x, y: old_y}
The key presses will move the entity in that direction by the speed passed in the argument.