Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 1000
Vincent Williams Avatar asked Nov 20 '25 00:11

Vincent Williams


1 Answers

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.

like image 155
Vincent Williams Avatar answered Nov 22 '25 13:11

Vincent Williams