且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检测,当一个演员被触摸的libgdx?

更新时间:2023-02-06 15:21:30

请参阅有关此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;
}