S
S
Sland Show2016-08-04 11:56:48
Java
Sland Show, 2016-08-04 11:56:48

Why is Tile Map not loading?

Good day to all.
I am writing a game using libGDX.
Made a map using Tile Map Editor. But it doesn't compile:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error parsing file: res/maps/level1.tmx
  at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:83)
  at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:78)
  at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:65)
  at com.project.demo.GameMenuScene.<init>(GameMenuScene.java:116)
  at com.project.demo.GameLoader.<init>(GameLoader.java:26)
  at com.project.demo.ProjectDemo.create(ProjectDemo.java:44)
  at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:147)
  at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: res\maps\level1.tmx (Internal)
  at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
  at com.badlogic.gdx.files.FileHandle.reader(FileHandle.java:163)
  at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:81)
  ... 7 more

The resources folder is in the assets folder , but it still throws an error.
Here are code snippets:
class GameScene extends GameState{

//GameState нужен для того, чтобы загружать классы в качестве уровней
//Т.е я привожу все уровни к одному типу и потом загружаю их переопределенные методы для отрисовки конкретного уровня. 


GameScene(){
//создание карты:
 tileMap = new TmxMapLoader().load("res/maps/level1.tmx");
 tmr = new OrthogonalTiledMapRenderer(tileMap);
 //code...   
}


 @Override
 public void render() {

    //фон
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //рисуем карту
    tmr.setView(cam);
    tmr.render();

    //физика
    b2dr.render(world,b2dCam.combined);

   }


 //code...

}

And here is a photo of my directories in the project:
55bc6b1455ce4db28ce29e9e586b1e0b.png
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
exenza, 2016-08-04
@SlandShow

1. check Run -> Edit Configurations -> Desktop (or whatever you call it) that Working directory = "your_project_path/core/assets"
2. make sure the file is in the maps folder (not visible on the screenshot)
3. transfer the file to the assets root and check
4. debug

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question