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.
Asked
Active
Viewed 2,978 times
2
-
It's not specifically geared toward LibGDX, but it does answer your question: http://stackoverflow.com/questions/2217670/android-how-to-detect-double-tap – laminatefish Nov 14 '14 at 16:46
-
Thanks lokisinclair but I wanted a libgdx specific answer. – Android Thoughts Nov 14 '14 at 20:16
2 Answers
7
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;
}
}

Enigo
- 3,685
- 5
- 29
- 54
2
There is an example of usage of GestureDetector with multiple tapping detection in one of libGDX's tests: GestureDetectorTest.java.

Alexander Mironov
- 3,095
- 26
- 28
-
Thanks a lot for your quick reply. It works well now. I changed the code a bit because I am currently not working worth cameras and I separated the Controller class from the main class to make it cleaner. This was my first question on stackoverflow and I am positively surprised by the fast answers. I'll definitely recommend this site to others. – Android Thoughts Nov 14 '14 at 20:15