问题
I currently have 2 classes, an Assets class and a loading screen class: Assets class:
public class Assets {
public static AssetManager manager = new AssetManager();
public static void queueLoading() {
(..)
manager.load("sound/startScreen.mp3", Music.class);
(..)
while(!manager.update())
{
System.out.println("Loaded: " + manager.getProgress() *100 + "%");
}
}
public static boolean isLoaded() {
if(manager.getProgress() >= 1)
return true;
return false;
//return manager.update();
}
}
Loading screen::
public class LoadingScreen implements Screen{
final Game1 game;
Sprite LdScreen;
OrthographicCamera camera;
public LoadingScreen(Game1 gam){
game=gam;
camera = new OrthographicCamera();
camera.setToOrtho(false, 1920, 1080);
}
public void show() {
Texture LdscreenTexture = new Texture(Gdx.files.internal("data/Background.png"));
LdScreen = new Sprite (LdscreenTexture);
}
@Override
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
game.batch.setProjectionMatrix(camera.combined);
game.batch.begin();
game.batch.draw(LdScreen, 0,0);
game.batch.end();
Assets.manager.update();
if(Assets.manager.update() == true){
game.setScreen(new MainMenuScreen(game));
System.out.print("test");
}
}
The problem is this doesn't work, when I run it immediately Assets.manager.update
returns true and I get an error saying that the assets are not found for MainMenuScreen
, clear as they have not been loaded. And when i comment out game.setScreen(new MainMenuScreen(game));
I get the 'test' written to the console but I don't get the progress to the console from my Assets class. This leads me to think that when I run I the Asset.smanager.update
always returns true, and it isn't loading the assets at all.
I have looked at tutorials and the wiki, but I have not found them to be useful. Any ideas?
来源:https://stackoverflow.com/questions/27468382/error-with-loading-screen-assetmanager-libgdx-java