I decided to take a different approach and load it with TmxMapLoader. I followed this tutorial. However I still get a lot of errors parsing the file. I was previously using XML encoding, so I changed it to base64 and also tried base64 with gzip compression, however I still get a lot of errors. Here’s the stack trace:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error parsing file: maps/tilemap.tmx
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:79)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:116)
at com.badlogic.gdx.maps.tiled.TmxMapLoader.load(TmxMapLoader.java:104)
at en.mash.splooke.maps.Map.loadMap(Map.java:19)
at en.mash.splooke.screen.GameScreen.show(GameScreen.java:40)
at com.badlogic.gdx.Game.setScreen(Game.java:62)
at en.mash.splooke.screen.SplashScreen.render(SplashScreen.java:28)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:207)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.SerializationException: Error parsing XML on line 1 near: <?xml version="1.0" encoding=
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:322)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:60)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:67)
at com.badlogic.gdx.utils.XmlReader.parse(XmlReader.java:77)
... 9 more
Also here is my TMX file:
<?xml version="1.0" encoding="utf-8"?>
<map version="1.0" orientation="orthogonal" width="200" height="32" tilewidth="32" tileheight="32">
<tileset firstgid="1" name="Blocks" tilewidth="32" tileheight="32" spacing="0" margin="0">
<image source="tiles.png" />
</tileset>
<layer name="Platforms" width="200" height="32">
<properties>
<property name="@Description" value="" />
</properties>
<data encoding="base64">this is mainly just A's, I removed it because it's so long</data>
</layer>
</map>
This is how I’m loading the map file:
public Map(String file) {
this.mapFile = file;
}
public void loadMap(float unitScale) {
map = new TmxMapLoader().load(mapFile);
renderer = new OrthogonalTiledMapRenderer(map, unitScale);
}
I checked the tutorial twice over and my code should work. ???