触地得住了libgdx

时间:2012-04-08 18:54:05

标签: android libgdx

在触地事件中是否有类似于libGdx(在Android中) - 因此当用户触摸屏幕(并且持续按下他们的手指)时,即。 touchhelddown方法?

1 个答案:

答案 0 :(得分:8)

您可以使用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作为参数提供给构造函数。

相关问题