我在 InputProcessor 的 touchDown 方法中的枚举遇到了一些问题。当我尝试使用它时,它会生成所有可能的枚举......
public class Memoration implements ApplicationListener, InputProcessor {
public static enum Screen {GAME, MENU}
Screen screen;
@Override
public void create() {
screen = Screen.MENU;
Gdx.app.log("onCreate", "works");
Gdx.input.setInputProcessor(this);
}
@Override
public void dispose() {
}
@Override
public void render() {
// bla bla bla
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
Gdx.app.log("touch", "down");
if(screen == null)
Gdx.app.log("screen", "null");
if(screen == Screen.MENU)
Gdx.app.log("screen", "menu");
if(screen == Screen.GAME)
Gdx.app.log("screen", "game");
return false;
}
}
日志显示“onCreate: workds”、“touch: down”、“screen: null”、“screen: menu”和“screen: game”