通过以下调用使应用程序全屏显示时:
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
我的 Controller 不再有信号。通过将显示从全屏更改回如:
Gdx.graphics.setWindowedMode(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
我使用的 Gdx 版本:1.9.8。看来这是以前版本中修复的问题,但我不确定要解决此问题需要采取哪些必要步骤。 以下是我发现的一些有关该问题的帖子:
https://github.com/libgdx/libgdx/issues/4723
https://github.com/GoranM/bdx/issues/518
(这个是旧的)http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=10692
非常感谢任何帮助。
<小时/>*编辑:这使用了可以从 libgdx 设置应用程序中检查的 Controller 扩展。 *
<小时/>Edit2:如果我重新轮询 Controller ,我可以获得响应式 Controller ,如下所示:
Array<Controller> controllers = Controllers.getControllers();
但是,更改显示模式后不能立即完成此操作;之后我必须等待一段时间。我不确定需要轮询什么来确定需要等待多长时间才能使 Controller 实例有效(此外,当分配监听器有效时)。
<小时/>Edit3:我能想到的唯一解决方案是在调整大小回调中设置一个标志,如下所示
@Override
public void resize(int width, int height) {
resizeDirty = true;
resizeTimestamp = System.currentTimeMillis();
}
然后在我的主循环中调用:
private void controllerCheck() {
if (resizeDirty) {
long currentTime = System.currentTimeMillis();
if (currentTime > resizeTimestamp + controllerResetDelay) {
resizeDirty = false;
//get new controller instance | re-add a controller listener
}
}
}
这并不理想,我宁愿找到一种方法来监听上下文更改何时完成初始化,然后更新 Controller 。但我一直没能找到一个钩子(Hook)。如果有人知道通过更改显示模式来维护 Controller 的更好方法,我将不胜感激。
最佳答案
为什么不尝试使用沉浸式全屏呢? 如果目标是设置全屏模式,我认为这是更好的方法。
关于java - 使应用程序全屏显示后 Libgdx Controller 无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47860490/