# Class VirtualJoystick

java.lang.Object
com.codename1.gaming.VirtualJoystick

public class VirtualJoystick extends Object

An on-screen analog stick. Add one with `TouchControls#addJoystick(float, float, float)`; the framework draws it and feeds its direction into `GameInput`, so the game reads it the same way whether the player uses touch or a keyboard:

- as analog axes via `GameInput#getAxisX()` / `GameInput#getAxisY()` (each -1..1, with x pointing right and y pointing down the screen), and
- as digital game actions: pushing the stick past its dead zone presses `com.codename1.ui.Display#GAME_LEFT` / `GAME_RIGHT` / `GAME_UP` / `GAME_DOWN`, so `GameInput#isGameKeyDown(int)` works unchanged.

Positions and sizes are in the `GameView`'s pixel coordinates (origin at the top left).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getAxisX()`
  `float`
  `getAxisY()`
  `float`
  `getCenterX()`
  `float`
  `getCenterY()`
  `float`
  `getKnobRadius()`
  `float`
  `getKnobX()`
  `float`
  `getKnobY()`
  `float`
  `getRadius()`
  `boolean`
  `isActive()`
  `VirtualJoystick`
  `setDeadZone(float deadZone)`
  The fraction of the radius that registers as no input (0..1, default 0.2).
  `VirtualJoystick`
  `setKnobRadius(float knobRadius)`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### setDeadZone

    public VirtualJoystick setDeadZone(float deadZone)
    The fraction of the radius that registers as no input (0..1, default 0.2).

  - ### setKnobRadius

    public VirtualJoystick setKnobRadius(float knobRadius)

  - ### isActive

    public boolean isActive()

  - ### getAxisX

    public float getAxisX()

  - ### getAxisY

    public float getAxisY()

  - ### getCenterX

    public float getCenterX()

  - ### getCenterY

    public float getCenterY()

  - ### getRadius

    public float getRadius()

  - ### getKnobRadius

    public float getKnobRadius()

  - ### getKnobX

    public float getKnobX()

  - ### getKnobY

    public float getKnobY()