Twoway Component

Move an entity left or right using the Left Arrow, Right Arrow keys or D and A and make it jump using Up Arrow or W. Simulates jumping and falling when used with the Gravity component.

This component is a thin wrapper around the Multiway and Jumper components and sets the appropriate key bindings. It is a well suited for side-scrolling platformer type games.


Back to top


public this .twoway([Number speed[, Number jumpSpeed]])

A speed in pixels per second


Vertical jump speed in pixels per second

Constructor to initialize the speed and power of jump. Component will listen for key events and move the entity in the respective direction by the speed passed in the argument. Pressing the jump key will cause the entity to jump with the supplied power.