Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGdx double tap

I want to detect double taps in libgdx using the tap method of the GestureDetector. GestureListener class. I searched the Web for the last two days but I couldn't find an example of how to do it. I know that the method has a "count" variable but I don't know how to use it. Thanks in advance.

like image 889
jakobwakob Avatar asked Jun 30 '26 13:06

jakobwakob


1 Answers

I believe that the accepted answer doesn't provide enough details, so here is a small code snippet with implementation:

public class DoubleTapDetector extends GestureDetector.GestureAdapter {

    @Override
    public boolean tap(float x, float y, int count, int button) {
        if (count == 2) {
            System.out.println("Double tap!");
            return true;
        }
        return false;
    }
}
like image 151
Enigo Avatar answered Jul 03 '26 01:07

Enigo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!