error: package com.badlogic.gdx.backends.lwjgl does not exist

error: package com.badlogic.gdx.backends.lwjgl does not exist

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

我把项目结构放在这里,如果有帮助的话。

我仍然无法将 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);