Skip to content

Touchpads

raeleus edited this page Aug 8, 2022 · 5 revisions

Touchpad

Touchpad is a specialized widget intended for touch screen control. It serves as a replacement for a physical joystick. It's mostly implemented in mobile games, but can be used on any platform.

TouchpadStyle

The style for Touchpad is very simple. It consists of only two drawables:

background

The background determines the preferred size of the widget. Consider making the image semi-transparent so that gameplay is not obstructed.

knob

This is the part of the Touchpad that the player will press to move the joystick. It must be sized within the bounds of the background.

Implementing Touchpad in your UI

You typically want your game to play underneath your Touchpad. A two viewport solution will work well in this case:

Check out the video on Viewports for more details.

Follow Mode Touchpad

Though there is not an official widget in Scene2D, the Touchpad can be hacked to emulate this behavior:

Further Steps

Continue with 12 - Window and Dialog or return to the table of contents.

Clone this wiki locally