Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How can i get user input in libgdx?


Asked by Kylian Lugo on Dec 06, 2021 FAQ



This tutorial walks through the classes and functions in libGDX that let you get and respond to user input. Getting user input from multiple devices can be tricky- a desktop application is different from a mobile app, which is different from a game embedded in a website. Luckily, libGDX exposes an API that generalizes to different devices.
Moreover,
Getting user input from multiple devices can be tricky- a desktop application is different from a mobile app, which is different from a game embedded in a website. Luckily, libGDX exposes an API that generalizes to different devices. Most of the functions will work on every platform.
Just so, The pointer value is value between 0 and n ( defined as 20 in LibGDX, in reality much lower ) that represents the ORDER in which the touch event occurred in the event of multiple simultaneous touches.
Subsequently,
At the end of the day, touches is basically identical to mouse clicks, except you can have multiple of them and there are no buttons. Oh I suppose I should mention that the 5 touch limit in this example was just an number I picked arbitrarily. LibGDX supports up to 20 touches although no devices do.
In addition,
Music is usually too big to be kept in memory completely, hence the differentiation. As a rule of thumb, you should use a Sound instance if your sample is shorter than 10 seconds, and a Music instance for longer audio pieces. Note: libGDX supports MP3, OGG and WAV files.