0
votes

I seem to be unable to properly load a texture from the "assets" folder in my libgdx project in Eclipse. My code is:

AssetManager am = new AssetManager();
am.load("football.png", Texture.class);
if(! am.isLoaded("football.png")) System.out.println("NOT loaded");

The "assets" folder is in the "/my-gdx-game-android", whereas the code above is called from the "/my-gdx-game-core/src/com/mygdx/game/MyGdxGame.java". I am absolutely sure the texture is there. However, I am constantly getting "NOT loaded" message. Obviously, I am doing something wrong here. Could you please help me?

1

1 Answers

0
votes

Problem solved. It turns out that AssetManager loads assets asynchronously. To get rid of the "NOT loaded" message, I had to put

am.finishLoading();

before

if(! am.isLoaded("football.png")) System.out.println("NOT loaded");

This method blocks the thread until all assets are loaded.