gpt4 book ai didi

java - 错误: package com. badlogic.gdx.backends.lwjgl不存在

转载 作者:行者123 更新时间:2023-12-01 17:53:32 25 4
gpt4 key购买 nike

我尝试使用 LwjglApplicationConfiguration.getDesktopDisplayMode(); 获取显示尺寸方法。我可以从 DesktopLauncher 使用它,但我需要在名为 MainMenuScreen 的类中使用它,该类扩展了 ApplicationAdapter。我导入了com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; ,但我仍然遇到同样的错误。

如果有帮助的话,我从这里放置了项目结构。

enter image description here

最佳答案

我仍然无法将 LwjglApplicationConfiguration 包导入到 MainMenuScreen,但我解决了为什么我需要 LwjglApplcationConfiguration 包,我需要它在 MainMenuScreen 中按屏幕宽度和高度缩放纹理,我只能从 LwjglApplcationConfiguration 包获取这些信息。在 DesktopLauncher 中,我们有用于显示 MainMenuScreen 的代码。

new LwjglApplication(new MainMenuScreen(), config);

然后我向 MainMenuScreen 编写了一个简单的构造函数:

public class MainMenuScreen extends ApplicationAdapter
{
//some methods and attributes in here.
private float ScreenHeight;
private float ScreenWidth;

public MainMenuScreen(float height, float width)
{
ScreenHeight = height;
ScreenWidth = width;
System.out.println("I got the datas! Height:" + ScreenHeight + ", width: " + ScreenWidth);
}
}

当然,我应该在开始时将 LwjglApplication() 中的 MainMenuScreen() 调用更改为:

new LwjglApplication(new MainMenuScreen(config.height, config.width), config);

关于java - 错误: package com. badlogic.gdx.backends.lwjgl不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60758452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com