Happy Coding

User Input

Now we know how to create a basic libGDX “game” that consists of some simple animated shapes bouncing around the scene. This demonstrates the lifecycle and animation framework that libGDX provides, but it’s not very interesting because it doesn’t respond to user input yet.

This is a companion discussion topic for the original entry at https://happycoding.io/tutorials/libgdx/input

Hi, I’m fairly new to Java so this might be a stupid question, but I was wondering why the touchDown function has the “(int x, int y, int pointer, int button)” parameters if the method itself just randomizes the colors and doesn’t use those variables?

1 Like

That’s a really good question!

It’s because in Java, when you override a function, you need to match the function signature exactly. In other words, you need to take all of the parameters that the function in the parent class or interface takes, even if you don’t use them in your function.

To see what I mean, try getting rid of the parameters, and you’ll see a compiler error!