Search code examples
androidfilelibgdxload

LibGdx Error Android Studio: Couldn't load file: Pictures/tileset_gutter.png


This appears when i want to load my .tmx file in Android Studio: The level1.tmx file such as the tileset_gutter.png are both in the assets directory. But i never declared tileset_gutter.png in my code so why does it show an error about it? Any advices?

E/AndroidRuntime: FATAL EXCEPTION: GLThread 96347
              Process: com.fraggy, PID: 15481
              com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: Pictures/tileset_gutter.png
                  at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:148)
                  at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
                  at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
                  at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:96)
                  at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:84)
                  at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:65)
                  at com.fraggy.Screens.PlayScreen.<init>(PlayScreen.java:41)
                  at com.fraggy.MainActivity.create(MainActivity.java:21)
                  at 

.....

This is my code: As you can see the

public class PlayScreen implements Screen {

private MainActivity game;
private OrthographicCamera  gamecam;
private Viewport gamePort;
private Hud hud;
private TmxMapLoader maploader;
private TiledMap map;
private OrthogonalTiledMapRenderer renderer;


public PlayScreen(MainActivity game){
    this.game = game;
    gamecam = new OrthographicCamera();
    gamePort = new FitViewport(MainActivity.V_WIDTH, MainActivity.V_WEIGHT, gamecam) ;
    hud = new Hud(game.batch);

    maploader = new TmxMapLoader();
    map = maploader.load("level1.tmx");
    renderer = new OrthogonalTiledMapRenderer(map);

    gamecam.position.set(gamePort.getWorldWidth()/2, gamePort.getWorldHeight()/2, 0);



}

public void update(float dt){
    handleInput(dt);

    gamecam.update();
    renderer.setView(gamecam);


}

private void handleInput(float dt) {
    if (Gdx.input.isTouched())
        gamecam.position.x += 100*dt;


}

Solution

  • The images used for a TMX file (tile map) are embedded in the map file itself. The default libgdx loader also loads the images defined in the tmx file.