A joystick object creates a virtual touch area of the screen which automatically tracks a users touch movements. When you create a joystick you specify a center location for the stick. You may also provide a sprite that follows the user's touch movements.
Joysticks in absolute mode have a radius around their centers inside which touches are registered. Once a touch is detected within a joystick's radius, an event is fired for which are routine can read various joystick parameters.

In absolute mode, joystick position values are relative to the center positions of the joystick. In the other mode, relative, the position values are relative to the last position of the joystick.
Joystick event values give position and angles of the joysticks position via a _joy variable.
Details below.


whether or not joystick is currently active
the location of the joystick on screen
relative (default) or absolute. Indicates if _joy expression values are relative to the last stick position or to the center of the joystick.
move={routine name}
the routine to run when the joystick is moved (touched and moved within the specified radius) create routine as OnJoyStick   if (_joy.direction=="up")     update var NewManDir set=1   elsif (_joy.direction=="right")     update var NewManDir set=2   elsif (_joy.direction=="down")     update var NewManDir set=4   elsif (_joy.direction=="left")     update var NewManDir set=8   endif   if (_joy.compass=="nw") Whatever() endif end
radius for detecting a touch on the joystick when mode is absolute.
sprite={sprite name}
a sprite to move with the drag of the joystick.

The routine called by 'move' will have access to the values below. They can be accessed as _joy.angle

_joy values

Angles are based on the unit circle where up is 90° and towards the right is 0°
the distance of the joystick's current position to the joystick's center position
the canvas x position of the touch
the canvas y position of the touch
the change in x position since last touch movement
the change in y position since last touch movement
the percentage of the distance from the center of the joystick to the radius for the joystick
doubled-quoted: up, down, left or right
doubled-quoted: n,ne,e,se,s,sw,w, or nw
the distance the stick moved since its last position