我使用的是 Stage,因此必须使用 InputMultiplexer 将输入发送到 Stage 和处理全屏 GWT 请求的 InputAdapter。
InputAdapter webGlfullscreen = new InputAdapter() {
@Override
public boolean keyUp (int keycode) {
if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
}
return true;
}
};
Gdx.input.setInputProcessor(new InputMultiplexer(webGlfullscreen, stage));
Run Code Online (Sandbox Code Playgroud)