Search code examples
javaandroidlibgdxmulti-touchjoystick

How to add a Touchpad in LibGDX


I made my own simple framework to use with LibGDX but I can't figure out how to make a TouchPad appear on the screen. I need two separate joysticks (LibGDX TouchPads) to be on the screen at once and both handle touch events.

How do I do this? I am able to declare the Touchpads and set their skin but I can't figure out how to display them and how to implement multi-touch.


Solution

  • I figured it out. All you have to do is add them to a Stage like so: stage.addActor(touchpad);, then in your render() method you say: stage.act(); stage.draw();. Unlike android, LibGDX handles multi-touch automatically.