简体   繁体   中英

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

i trying to get display dimensions with using LwjglApplicationConfiguration.getDesktopDisplayMode(); method. I can use it from DesktopLauncher, but i need use in a class named MainMenuScreen, which extends ApplicationAdapter. I imported 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. In the DesktopLauncher, we have this code for show MainMenuScreen.

new LwjglApplication(new MainMenuScreen(), config);

Then i wrote a simple constructor to MainMenuScreen as:

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM