Landing is constrained by libgdx

Is there an equivalent in libGdx (in Android), for example on landing, so when the user touches the screen (and keeps his finger down constantly), i.e. touchhelddown method?

+3


source to share


1 answer


You can use GestureDetector

. It implements InputAdapter

, so you can use it instead of your InputAdapter or in conjunction with your InputAdapter using InputMultiplexer

.

You need to specify GestureListener

. GestureDetector calls the GestureListener methods when it detects supported gestures. These methods and gestures are:



public boolean touchDown (int x, int y, int pointer);
public boolean tap (int x, int y, int count);
public boolean longPress (int x, int y);
public boolean fling (float velocityX, float velocityY);
public boolean pan (int x, int y, int deltaX, int deltaY);
public boolean zoom (float originalDistance, float currentDistance);
public boolean pinch (Vector2 initialFirstPointer, Vector2 initialSecondPointer, 
                      Vector2 firstPointer, Vector2 secondPointer);

      

You can extend GestureAdapter

and override the method that interests you. In your case, you will override the method longPress

. You can also specify longPressDuration

as a parameter to the constructor.

+8


source







All Articles