0

I am following a java tiled game tutorial using libGDX and I met the following errors :

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: gaming creation/herbe16.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:142)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:112)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:108)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:119)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:104)
at com.poussins.screens.Play.show(Play.java:35)
at com.badlogic.gdx.Game.setScreen(Game.java:62)
at com.poussins.Poussins.create(Poussins.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: gaming creation/herbe16.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:133)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:563)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:218)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 12 more

here is the code i'm using in the Play class :

package com.poussins.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;

public class Play implements Screen{

private TiledMap map;
private OrthogonalTiledMapRenderer renderer;
private OrthographicCamera camera;

@Override
public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    renderer.setView(camera);
    renderer.render();
}

@Override
public void resize(int width, int height) {
    camera.viewportWidth = width;
    camera.viewportHeight = height;
    camera.update();        
}

@Override
public void show() {
    map = new TmxMapLoader().load("maps/map-Herbe-Goudron.tmx");

    renderer = new OrthogonalTiledMapRenderer(map);

    camera = new OrthographicCamera();
}

@Override
public void hide() {
    dispose();

}

@Override
public void pause() {
    // TODO Auto-generated method stub

}

@Override
public void resume() {
    // TODO Auto-generated method stub

}

@Override
public void dispose() {
    map.dispose();
    renderer.dispose();     
}

}

In order to put the .tmx map into the Eclipse project, I just made a Copy (from the folder where the .tmx map is) and a paste in the Eclipse project named "Poussins-Desktop / assets / maps". I used the same actions (copy paste) to give the .png tiles to the same Eclipse project named "Poussins-Desktop / assets / maps" (can see it in the screenshots). In the code, I am not sure with this following line :

map = new TmxMapLoader().load("maps/map-Herbe-Goudron.tmx");

because I don't know if the path to the .tmx is good, but it seem to respect what was said in the tutorial ...

In fact, in the error, it is saying that the file herbe16.png cannot be loaded. but this file is a tile from the whole .tmx map.

I am working on UBUNTU 13.10 system, Eclipse 3.8.1

I hope someone will help me and I thank you in advance for paying attention to my problem.

nKn
  • 13,691
  • 9
  • 45
  • 62
  • The error message is pretty obvious. You have to put the file herbe16.png in `android/assets/creation/herbe16.png`. The tile pictures are, of course, also loaded when loading the map. – noone May 03 '14 at 05:32

2 Answers2

0

Okay, I don't know if this will help you.. I was just declaring the path for my files not minding caps letters (I'm using windows7).

Now, when I tested the code as a java application on my desktop it was going smoothly but when I tried launching it on an emulator or an android device it would crash.

Turns out that the emulator and device both need the exact path with capital letters.

nstsgr
  • 3
  • 4
  • Windows is case-insensitive (in most cases), *unlike* most other operating systems. I suppose a lot of people don't know about it. –  Oct 07 '14 at 16:42
0

This may have already been solved or the OP may have given up on it, but I came across this error too on the same tutorial. I solved the issue in my case. It may be possible that the OP was using a .png of a different bit depth (as was in my case). The .png that caused the error was 64 bit depth (you can check by right clicking on the .png -> PROPERTIES -> DETAILS). Using a .png of a bit depth of 32 allowed the loading to work perfectly fine. I used photoshop to create my .png tileset, and when creating the new file, set it to 8 bit (next to the color mode).

edragon53
  • 1
  • 1