Search code examples
androidlibgdxtouch

Save touches on libgdx


Is it possible to save first touch, release and then read second or new touches while rendering libgdx? I've only found this Gdx.input.isTouched (int) while int is the index for how many fingers at the same time, but I need releasethe first and then do more touches.

If this question is answered before, where?


Solution

  • I assume you want to safe the coordinates of the touch?

    Gdx.justTouched will only run a single time until released. Or you can implement GestureListener and use it's tap(int x, int y, int button) method.

    So just store Gdx.input.getX and Gdx.input.getY when a touch is detected and you have these saved until you save the next touch over it again.