问题
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