It is not as easy as just putting the atlas property to the source.
That property would not be used, because the tiles described in the xml don't reference the atlas at all.
What you need is to let the TiledMapPacker
run over your files. It will preprocess your map, create an optimized atlas file and add the property to the xml. Only then you can use the AltasTmxMapLoader
to load that file correctly.
See my posts here for an explanation of how I got that to work.
The tools in the official distributions of libgdx should include all necessary things. I got it to run with this command:
java -classpath "gdx.jar";"gdx-natives.jar";"gdx-backend-lwjgl.jar";"gdx-backend-lwjgl-natives.jar";"gdx-tools.jar";"gdx-tiled-preprocessor.jar" com.badlogic.gdx.tiledmappacker.TiledMapPacker "processed/input" "processed/output" "--strip-unused"
To run it from code put this inside of the core-main Class/project:
Settings settings = new Settings();
settings.maxWidth = 2048; //modify if needed
settings.maxHeight = 2048; //modify if needed
settings.fast = true; //fast should be fine here!
//all tiles have a 1px padding. better for not getting artifacts
TiledMapPacker pack = new TiledMapPacker();
try
{
pack.processMaps(
new File(
"PATH-TO-INTPUT"),
new File(
"PATH-TO-OUTPUT"),
settings);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}