package de.gurkenlabs.litiengine.environment.tilemap;

import de.gurkenlabs.litiengine.environment.tilemap.xml.Map;
import de.gurkenlabs.litiengine.environment.tilemap.xml.Tileset;
import de.gurkenlabs.litiengine.util.io.FileUtilities;
import de.gurkenlabs.litiengine.util.io.XmlUtilities;

/**
 * This class allows to deserialzie a tmx file into an IMap instance.
 */
public final class TmxMapLoader implements IMapLoader {

  @Override
  public IMap loadMap(final String path) {
    final Map map = XmlUtilities.readFromFile(Map.class, path);
    if (map == null) {
      return null;
    }

    String basePath = FileUtilities.getParentDirPath(path);
    for (Tileset tilesets : map.getRawTileSets()) {
      tilesets.loadFromSource(basePath);
    }

    // by default the map is named by the source file
    String name = FileUtilities.getFileName(path);

    map.setFileName(name);
    map.setPath(path);
    map.updateTileTerrain();

    return map;
  }
}
@@ -332,10 +332,10 @@
 rial
-z
 i
+z
 e a 
@@ -429,16 +429,118 @@
 ader %7B%0D%0A
+  public static final TmxMapLoader INSTANCE = new TmxMapLoader();%0D%0A  %0D%0A  private TmxMapLoader() %7B%7D%0D%0A  
 %0D%0A  @Ove
@@ -1089,8 +1089,10 @@
 %0D%0A  %7D%0D%0A%7D
+%0D%0A

Use singleton structure for TmxMapLoader