android - 如何检测 libgdx 中的 Actor 何时被触摸?

标签 android touch sprite libgdx

我在我的 Screen 方法的渲染方法中使用“Gdx.input.isTouched()”来了解触摸的位置,但是当在屏幕中拖动触摸时,它也会激活我想要的事件,只有当 Actor 很感动。

是否有任何监听器知道何时触摸了 Actor,但事件不是被拖动的事件,我是用 sprite 做的。

最佳答案

请参阅有关 scene2d 的维基页面在 LibGDX 中。特别是关于输入处理的部分。

基本上,您必须在您的 Actor 中覆盖这些方法中的一个或多个:

public boolean touchDown (float x, float y, int pointer) {
    return false;
}

public void touchUp (float x, float y, int pointer) {
}

public void touchDragged (float x, float y, int pointer) {
}

public boolean touchMoved (float x, float y) {
    return false;
}

public boolean scrolled (int amount) {
    return false;
}

public boolean keyDown (int keycode) {
    return false;
}

public boolean keyUp (int keycode) {
    return false;
}

public boolean keyTyped (char character) {
    return false;
}

关于android - 如何检测 libgdx 中的 Actor 何时被触摸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9236175/

相关文章:

安卓 : Touch events in layout after animation

rollover - 如何在内联元素中优雅地使用 css sprites?

python - 滑动 Sprite

android - React-native - npm-start 不工作 - 地铁出错 - events.js :183 throw er

android - 使用 Android Studio 3+ 监控线程正在执行的内容

html - ionic 3 中的 touchstart 和 touchend 事件

c# - 统一导入 WWW 后如何更改 Sprite 的每单位像素?

android - AnimationDrawable 内存不足问题

android - 禁用自动下载 APK 扩展文件

android - 如何创建一个不规则形状的图像按钮,其中图像的透明部分不可点击?