Twoway
Move an entity left or right using the arrow keys or D and A and jump using up arrow or W.
When direction changes a NewDirection event is triggered with an object detailing the new direction: {x: x_movement, y: y_movement}. This is consistent with Fourway and Multiway components. When entity has moved on x-axis a Moved event is triggered with an object specifying the old position {x: old_x, y: old_y}
.twoway
public this .twoway(Number speed[, Number jumpSpeed])
- speed
- Amount of pixels to move left or right
- jumpSpeed
- How high the entity should jump
Constructor to initialize the speed and power of jump. Component will listen for key events and move the entity appropriately. This includes
`Up Arrow`, `Right Arrow`, `Left Arrow` as well as W, A, D. Used with the
`gravity` component to simulate jumping.
The key presses will move the entity in that direction by the speed passed in
the argument. Pressing the Up Arrow or W will cause the entity to jump.

@craftyjs
#crafty@freenode.net
google groups
louis@craftyjs.com
github