libgdx actor touchHandling

拈花ヽ惹草 提交于 2019-12-12 02:55:18

问题


I am currently experience some funny issue with touchHandling on LibGdx . My code is as follows:-

testCount=0;
ThisButton.addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    testCount++;
    gameLog("touchDown - testCount: " + testCount);
    return true;
}
public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
    testCount++;
    gameLog("touchUp - testCount: " + testCount);
}

});

Theoretically, testCount should only return 2 (1 for touchDown, and 1 for touchUp) when the actor are touched. However, my LogCat output returns multiple calls on single tapped.

GreatGame: GameScreen: touchDown - testCount: 1
GreatGame: GameScreen: touchDown - testCount: 2
.
.
.
GreatGame: GameScreen: touchDown - testCount: 177
GreatGame: GameScreen: touchDown - testCount: 178
GreatGame: GameScreen: touchUp - testCount: 179
GreatGame: GameScreen: touchUp - testCount: 180
.
.
.
GreatGame: GameScreen: touchUp - testCount: 355
GreatGame: GameScreen: touchUp - testCount: 356

I am not sure where I went wrong.

Thank you very much and your help is much appreciated.

Regards Zi

来源:https://stackoverflow.com/questions/20798403/libgdx-actor-touchhandling

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