在libGdx(Android)中是否有类似于触摸事件的等效方法,即当用户触摸屏幕并持续按住手指时,例如touchhelddown方法?
GestureDetector
。它实现了InputAdapter
,因此你可以使用它代替你的InputAdapter
或与你的InputAdapter
一起使用InputMultiplexer
。GestureListener
。当检测到支持的手势时,GestureDetector会调用GestureListener的方法。这些方法和手势包括: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);
您可以扩展GestureAdapter
并覆盖您感兴趣的方法。在您的情况下,您将覆盖longPress
方法。您还可以将longPressDuration
作为参数提供给构造函数。