【发布时间】:2012-04-08 18:54:04
【问题描述】:
在 libGdx(在 Android 中)中是否有类似 touchdown 事件的等价物 - 所以当用户触摸屏幕(并连续按住手指)时,即touchhelddown 方法?
【问题讨论】:
在 libGdx(在 Android 中)中是否有类似 touchdown 事件的等价物 - 所以当用户触摸屏幕(并连续按住手指)时,即touchhelddown 方法?
【问题讨论】:
您可以使用GestureDetector。它实现了InputAdapter,因此您可以使用它来代替您的 InputAdapter 或使用 InputMultiplexer 与您的 InputAdapter 一起使用。
您需要为其提供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 作为参数提供给构造函数。
【讨论】: