如何检测,当一个演员被触摸的libgdx? [英] How to detect when an actor is touched in libgdx?

查看:244
本文介绍了如何检测,当一个演员被触摸的libgdx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Gdx.input.isTouched()在我的屏幕方式的渲染方法,知道在哪里被触及,但是当触摸被拖动屏幕,这也激活了事件我只当希望演员感动。

I am using "Gdx.input.isTouched()" in the render method of my Screen method, to know where is touched, but when the touch is dragged in the screen, it also activates the events i want only when an actor is touched.

有没有听众知道当一个演员被触及,但事件不拖之一,即时通讯做它用精灵。

Is there any listener to know when an Actor is touched, but the event is not the dragged one, im doing it with sprites.

推荐答案

请参阅有关此Wiki网页 scene2d 在LibGDX。特别是关于输入处理的部分。

See this wiki page about scene2d in LibGDX. Specifically the part about Input handling.

基本上你要覆盖一个在你的演员或多个这些方法:

Basically you have to override one or more of these methods in your 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;
}

这篇关于如何检测,当一个演员被触摸的libgdx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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