public class VirtualJoystick
- Object
- VirtualJoystick
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, soGameInput#isGameKeyDown(int)works unchanged.
Positions and sizes are in the GameView’s pixel coordinates (origin at the top
left).
Methods
Inherited methods
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()