0

=====================================

I was able to fix it by selecting the assets folder and choosing "use as source folder". It wasn't shown in the tutorial.

=====================================

I am trying to follow along a tutorial series on gdx java graphics programming.

But I am stuck trying to load a texture.

Error:

    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: dataack.PNG
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.myGame.Assets.load(Assets.java:17)
at com.myGame.MyGame.create(MyGame.java:11)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: dataack.PNG (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 9 more

And this is the code:

    public class Assets {


public static Sprite sprite_back;
public static Texture texture_back;

public static void load() {


    texture_back = new Texture(Gdx.files.internal("data/back.png"));
    texture_back.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    sprite_back = new Sprite(texture_back);
    sprite_back.flip(false, true);
}
}

This is the folder strucure: Assets>data>back.png Gdx.files.internal should start in the folder assets and therefore this should work. The image is in both the desktop and android assets folder and i also refreshed the project ecplorer.

I also tried putting it directly into the assets folder and loading it like this:

    texture_back = new Texture(Gdx.files.internal("back.png"));

but that didn't work either. I also don't know why the error log says "dataack.PNG" when the code says "data/back.png"

  • You said you're using C#? Maybe either C# or whatever middleware you're using to transfer C# to Java is treating `/` as an escape character, so `/b` is getting replaced or deleted. – Tenfour04 May 11 '14 at 02:27
  • I mistyped, i am using java and when i tried without any slash by putting the file in the base folder, it also didn't work – user3624333 May 11 '14 at 08:28
  • You might want to update to the latest version of libgdx (1.0.1). It now has a more streamlined directory structure based on Gradle. Now all the files are stored in the Android project's `assets` folder, and all other projects, like the desktop project, reference that same folder. You'll be able to get more help if you're up to date, and maybe this issue will just be fixed after you switch over. – Tenfour04 May 11 '14 at 12:54

0 Answers0