libgdx演员touchHandling

时间:2013-12-27 09:47:18

标签: java android touch libgdx

我目前在LibGdx上使用touchHandling遇到了一些有趣的问题。我的代码如下: -

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);
}

});

理论上,当触摸演员时,testCount应该只返回2(触摸1为1,触摸1为1)。但是,我的LogCat输出会在单击时返回多个调用。

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

我不确定我哪里出错了。

非常感谢,非常感谢您的帮助。

此致 子

0 个答案:

没有答案