# LibGDX GestureDetector touchUp

I am using to GestureDetector to detect drag gesture and determine vector based on position my finger first touched the screen and position when my finger left the screen. I already know that I can get coordinates where my finger touched the screen using touchDown(), but as far as I know there is no touchUp() in GestureDetector.

I tried to acieve this using fling(), but the problem with fling is that it has to be quick, otherwise it is not counted as fling.

pan() would be good, but it doesn't tell you if your finger left the screen.

So is there a way to detect touchUp? Or is there maybe another/better way to achieve what I want?

I don't use GestureListener, but rather track fingers in my own InputProcessor overrides. This allows huge flexibility, and gives me a rich set of input data, without worrying about some of it being stolen by another listener. I can't make out exactly what you're trying to accomplish, but by doing something similar, you can do just about anything.

The designers did a good job on the interface, so with just a bit of creative calculation and keeping track (in class-level variables) of things, you can implement just about anything.

For instance, I implement an On-Screen virtual D-Pad. Where I treat the first touch via overridden touchDown() to be the origin of the D-Pad, storing the origin and the "pointer" (finger id) in class-level vars. When the class is initialized, the finger Id is set to -1, so I can easily check uninitialized state.

Then, using those state variables, and processing touchDragged() and touchUp(), I can tell when the user is dragging around, calculating a "heading vector" as the delta from the stored origin to the current screenX and screenY passed into touchDragged(). I can tell when another finger is tapped (which I treat as an "action button").

My current game doesn't utilze fixed-position controls, rather wherever the user wants to touch on the screen becomes the origin of the D-Pad until that finger is raised, then the origin becomes wherever they touch again (likely a different place than previously). This is to avoid controls getting in the way of in-game action.

For instance: It's easy to implement a radius of "dead spot" around the origin to filter of superfluous jitter around the origin. By using the pythagorean theorem to calculate the distance from the origin to the current screenX, screenY, and ignoring values with a distance less than some value.

It would be easy to implemnt a follower that just cached the screenX, screenY at each call into touchDragged(), and compared that cached value to the current value, so you could derive a detla-vector.

Good luck!

Since the GestureListener consumes all its InputProcessor events to transform basic events into gesture events. The best way would probably be implementing a separated InputProcessor to catch the touchUp().

You instatiate a new InputMultiplexer and plug it to the applications instead of the Gesture Listener, then you plug your new InputProcessor and the GestureListener to the multiplexer.

Gesture Detection
Event Handling (also a bit over InputMultiplexer)