Class: Joystick

Structure which simulates a hardware joystick.

During development you can select "Human" from the control dropdown and you will be able to control a character using the keyboard in your browser. This can be useful to play against an agent you've created to test for weaknesses. The keybindings are described in "Properties" below.

Properties

direction {enum | null}

Can be one of the direction constants: UP, UP_RIGHT, RIGHT, DOWN_RIGHT, DOWN, DOWN_LEFT, LEFT, or UP_LEFT. Also can be set to a falsy value to represent no direction or center. When playing on a keyboard direction is bound to the arrow keys.

punchLight {boolean}

Light punch button, also called "jab". Bound to "A" key.

punchMedium {boolean}

Medium punch button, also called "fierce". Bound to "S" key.

punchHeavy {boolean}

Heavy punch button, also called "strong". Bound to "D" key.

kickLight {boolean}

Light kick button, also called "short". Bound to "Z" key.

kickMedium {boolean}

Medium kick button, also called "forward". Bound to "X" key.

kickHeavy {boolean}

Heavy kick button, also called "roundhouse". Bound to "C" key.

Methods

reset()

Reset joystick state to default.

copyFrom(Joystick)

Copy another joystick's state to this instance.

Parameters

Joystick {Joystick}

to copy from.