0
votes

Edit: It looks like eclipse couldn't synchronize folders between projects, I had to clean projects and refresh asset folders.


i'm trying to make a game in Java using libgdx. Everything works fine in Eclipse debug, but when I export it to JRE it can't load my textures(standard libgdx.png texture works great). I add texture to project by dragging and dropping it to data folder, selecting "copy" option. In code i'm loading it using this code:

texture = new Texture(Gdx.files.internal("data/player.png"));

In eclipse's debug it works. Project exported to jre can't load textures(all textures are in jar file), it shows those errors:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeExcepti
on: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/player.
png
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplicati
on.java:113)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/
player.png
        at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
        at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTexture
Data.java:64)
        at com.badlogic.gdx.graphics.Texture.load(Texture.java:175)
        at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
        at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
        at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
        at com.me.mygdxgame.MyGdxGame.create(MyGdxGame.java:29)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplic
ation.java:127)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplicati
on.java:110)
Caused by: java.io.IOException: couldn't load pixmap 8bit only
        at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.<init>(Gdx2DPixmap.java:57)

        at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:138)
        ... 8 more

My launch configuration is just like a normal configuration but with main class set as Main from desktop project.

1

1 Answers

0
votes

There is no such thing as reserved Texture names. If you got it working only changing the png image name. Then, your problem was that eclipse and your assets folder weren't correctly synchronized.

If you edit, delete or add a file into your project folders from outside eclipse (for example Windows Explorer), eclipse won't know till you refresh it.