Reputation: 29
I am using a GestureListener in LibGDX but there isn't really a method that will get recalled for the duration that they are holding there finger in the same spot on the screen, basically for as long as there holding there finger in the same spot on the screen I want it to call a method. How would I manage to do this in code because when I research and can't find any information on this.
Upvotes: 1
Views: 148
Reputation: 10320
What you looking for is Input Polling. As link only answers may lose its value if the link breaks (pretty common). This is a transcription.
To check whether one or more fingers are currently on the screen (which is equivalent to a mouse button being pressed) you can do the following:
boolean isTouched = Gdx.input.isTouched();
For multi-touch input you might be interested whether a specific finger (pointer) is currently on the screen:
// Will Return whether the screen is currently touched
boolean firstFingerTouching = Gdx.input.isTouched(0);
boolean secondFingerTouching = Gdx.input.isTouched(1);
boolean thirdFingerTouching = Gdx.input.isTouched(2);
To get the coordinates of a specific finger you can use the following methods:
int firstX = Gdx.input.getX();
int firstY = Gdx.input.getY();
int secondX = Gdx.input.getX(1);
int secondY = Gdx.input.getY(1);
Then you can simply poll the input every update to meet your requirements.
basically for as long as there holding there finger in the same spot on the screen I want it to call a method
Upvotes: 1