[英]error: package com.badlogic.gdx.backends.lwjgl does not exist
i trying to get display dimensions with using LwjglApplicationConfiguration.getDesktopDisplayMode();
我尝试使用
LwjglApplicationConfiguration.getDesktopDisplayMode();
获取显示尺寸LwjglApplicationConfiguration.getDesktopDisplayMode();
method.方法。 I can use it from DesktopLauncher, but i need use in a class named MainMenuScreen, which extends ApplicationAdapter.
我可以从 DesktopLauncher 使用它,但我需要在名为 MainMenuScreen 的类中使用它,它扩展了 ApplicationAdapter。 I imported
com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
我导入了
com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
, but i still get same error. ,但我仍然遇到同样的错误。
I put project structure from here, if it helps.如果有帮助,我将项目结构放在此处。
I still have no way to import LwjglApplicationConfiguration package to MainMenuScreen, but i solved the why i need LwjglApplcationConfiguration package, i need it for scale textures by screen width and height in MainMenuScreen i can only get these informations from LwjglApplcationConfiguration package.我仍然无法将 LwjglApplicationConfiguration 包导入 MainMenuScreen,但我解决了为什么我需要 LwjglApplcationConfiguration 包的原因,我需要它在 MainMenuScreen 中按屏幕宽度和高度缩放纹理我只能从 LwjglApplcationConfiguration 包中获取这些信息。 In the DesktopLauncher, we have this code for show MainMenuScreen.
在 DesktopLauncher 中,我们有这个用于显示 MainMenuScreen 的代码。
new LwjglApplication(new MainMenuScreen(), config);
Then i wrote a simple constructor to MainMenuScreen as:然后我向 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);
}
}
Of course, i should have change the MainMenuScreen() calling in LwjglApplication() at the begining as:当然,我应该在开始时将 LwjglApplication() 中的 MainMenuScreen() 调用更改为:
new LwjglApplication(new MainMenuScreen(config.height, config.width), config);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.