Search code examples
androidlibgdx

Libgdx cant find new TextureAtlas


I'm new to libgdx, and I get this exception:

com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: C:/Users/myname/Desktop/myLibgdxGame/android/assets/sprites.png/sprites.png

on the following function on the textureAtlas = new TextureAtlas("sprites.txt"); line and I can't understand what's wrong.

@Override
    public void create() {

        batch = new SpriteBatch();

        textureAtlas = new TextureAtlas("sprites.txt");
        banana = textureAtlas.createSprite("spr");


    }

Anyone knows what is the problem?
Thank you!


Solution

  • The path which you have given for texture atlas is wrong . In your case, Run time exception occurs because the java is unable to locate your texture atlas. So make sure that the texture atlas path is correct.