LibGdx KeyUp不工作
当使用以下代码时LibGdx KeyUp不工作,libgdx,Libgdx,当使用以下代码时 public static boolean isDown; public boolean keyDown(int key) { if (key == Keys.SPACE) { isDown = true; KeyMethods.testKeyDown(); } if (key == Keys.DOWN) { KeyMethods.testKeyPressed(); } return fa
public static boolean isDown;
public boolean keyDown(int key) {
if (key == Keys.SPACE) {
isDown = true;
KeyMethods.testKeyDown();
}
if (key == Keys.DOWN) {
KeyMethods.testKeyPressed();
}
return false;
}
public boolean keyUp(int key) {
if (key == Keys.SPACE) {
isDown = false;
}
return false;
}
键控未将isDow设置为false。testKeyDown:
public static void testKeyDown() {
while (GameKeyListener.isDown) {
System.out.println("Down");
}
}
它只是创建了一个无限循环。还有其他方法吗?您必须在keyDown/keyUp方法的最后返回true。这表示事件已被处理