Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java libgdx演员触摸处理_Java_Android_Touch_Libgdx - Fatal编程技术网

Java libgdx演员触摸处理

Java libgdx演员触摸处理,java,android,touch,libgdx,Java,Android,Touch,Libgdx,我目前在LibGdx上遇到了一些关于触摸处理的有趣问题。我的代码如下:- testCount=0; ThisButton.addListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { testCount++; gameLog("touchDown - testCount: " + testCount

我目前在LibGdx上遇到了一些关于触摸处理的有趣问题。我的代码如下:-

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用于触碰演员时的触地。但是,我的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
我不确定哪里出了错

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

问候
Zi

必须在其他设备上试用吗?谢谢,伙计,我已经在我的三星android和桌面上试用过了。在台式机和安卓手机上的结果相同。不知道哪里错了这确实不是我所期望的行为。也许可以尝试使用我刚刚测试过的ClickListener,代码可以完美地工作,使用Gdx.app.logTAG,着地-testCount:+testCount;当然,你的问题不是你的gameLog方法,而是你代码的其他部分,或者可能是你设备屏幕上的一个bug