touchdown held down libgdx

ⅰ亾dé卋堺 提交于 2019-11-30 18:14:53

问题


Is there an equivalent in libGdx (in Android) like the touchdown event - so when a user touches the screen (and holds their finger down continuously),i.e. touchhelddown method?


回答1:


You can use GestureDetector. It implements InputAdapter so you can use it instead of your InputAdapter or along with your InputAdapter using InputMultiplexer.

You need to provide a GestureListener to it. GestureDetector calls GestureListener's 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 you are interested in. In your case you will override longPress method. You can also provide longPressDuration as a parameter to constructor.



来源:https://stackoverflow.com/questions/10065467/touchdown-held-down-libgdx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!