I'm new to LibGdx, and have problem with input handling.
My player needs to shoot bullets whenever touch is down. But it seems that this method is called just once...
And then user have to click again to shoot another bullet.
I want always to shoot bullets while click is down...
Is there a way to handle this use case?
Look into "polling" on the touch input, instead of getting Input events. So, in your render or update method, use something like this:
boolean activeTouch = false;
if (Gdx.input.isTouched(0)) {
if (activeTouch) {
// continuing a touch ...
} else {
// starting a new touch ..
activeTouch = true;
}
} else {
activeTouch = false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With