Joystick
Dill Pixel includes a built-in virtual joystick component that provides touch-based directional input for games. The Joystick class is based on the pixi-virtual-joystick library but has been ported to TypeScript and adapted specifically for Dill Pixel.
Usage
Here’s a basic example of creating a joystick:
The joystick provides:
- Directional input (up, down, left, right and diagonals)
- Power/intensity value based on distance from center
- Angle information in degrees
- Touch/pointer event handling
- Customizable appearance
- Threshold setting to control dead zone
While the joystick comes with a default skin (simple black circles), you can easily customize its appearance by providing your own textures for the outer base and inner handle through the constructor options.
Using the Joystick with the Actions Plugin
To use the joystick with the action system, you need to:
- Register it with touch controls:
- Map joystick directions to actions in your config:
You can see examples of the joystick implementation in the physics demo scenes: