javajsonlibgdxasset-management

GdxRuntimeException: Asset not loaded


I'm following this tutorial, but instead if xml i use json. I think that the asset is loaded but apparently it's not! Would be nice if one of you have any solution.

The code is on github.

That is the output:

SUCCESS!
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Asset not loaded: core\assets\badlogic.jpg
    at com.badlogic.gdx.assets.AssetManager.get(AssetManager.java:150)
    at epytotorp.managers.AssetManager.get(AssetManager.java:78)
    at epytotorp.Game.create(Game.java:18)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)

Process finished with exit code 0

I tryed many thinks but none of them worked can you pls help me. Many thanks in advance.


Solution

  • With the Java libraries for dealing with files, you can safely use / (slash, not backslash) on all platforms. The library code handles translating things into platform-specific paths internally.

    I made some modification in your create() method of your Game game and then it's works.

    @Override
    public void create() {
        AssetManager.getInstance().initialize("core/assets/test.json");
        AssetManager.getInstance().load("group 1");
        AssetManager.getInstance().finishLoading();
        System.out.println("SUCCESS!");
        Texture texture = AssetManager.getInstance().get("core/assets/badlogic.jpg", Texture.class);
    
        System.out.println("Texture"+texture);
    
        ScreenManager.getInstance().initialize(this);
        ScreenManager.getInstance().setScreen(ScreenEnum.SPLASH);
    }