着陆按住libgdx [英] touchdown held down libgdx

查看:134
本文介绍了着陆按住libgdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有libGdx(Android中)等效像触下事件 - 所以当用户触摸屏幕时(并保持自己的手指不断下降),即touchhelddown方法?

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?

推荐答案

您可以使用<一个href="http://$c$c.google.com/searchframe#c5txscj0tnc/trunk/gdx/src/com/badlogic/gdx/input/GestureDetector.java&q=gesturedetector%20package%3ahttp://libgdx%5C.google$c$c%5C.com"><$c$c>GestureDetector.它实现了 InputAdapter 这样你就可以使用,而不是你InputAdapter或一起使用InputAdapter为 InputMultiplexer

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

您需要提供一个 GestureListener 给它。 GestureDetector称之为检测支持手势时GestureListener的方法。这些方法和手势是:

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);

您可以扩展 GestureAdapter 并重写你感兴趣的方法,在你的情况,你将覆盖长preSS 方法。您还可以提供长pressDuration 作为参数的构造函数。

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.

这篇关于着陆按住libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆