I started about a week ago with libGDX and I have a problem loading in a tmx. Tiled Map. As far as I see the game doesn't find the "test.tmx", but I don't know why! The path is correct as far as I can see.
I use "Tiled" as the Map Editor. The Layer Format is Base64.
This Screenshot showing the Code I use to load in the tmx. file and the Project Structure: http://abload.de/img/tmxgpptc.png
I get the following error Message:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error parsing file: res/map/test.tmx
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:83)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:113)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:101)
at de.knightsquest.states.Play.<init>(Play.java:59)
at de.knightsquest.handler.GameStateManager.getState(GameStateManager.java:35)
at de.knightsquest.handler.GameStateManager.pushState(GameStateManager.java:46)
at de.knightsquest.handler.GameStateManager.<init>(GameStateManager.java:20)
at de.knightsquest.game.Game.create(Game.java:38)
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: res\map\test.tmx (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.reader(FileHandle.java:164)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:81)
... 9 more
You should read this wiki article about file handling.
You have to place the res\map\test.tmx
inside your android project in the assets
folder. The way you load the map assumes an internal (android/assets) file path.
Furthermore I'd advise you to load the TiledMap
via an AssetManager
.