use of com.badlogic.gdx.maps.ImageResolver.DirectImageResolver in project libgdx by libgdx.
the class TideMapLoader method load.
public TiledMap load(String fileName) {
try {
FileHandle tideFile = resolve(fileName);
root = xml.parse(tideFile);
ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();
for (FileHandle textureFile : loadTileSheets(root, tideFile)) {
textures.put(textureFile.path(), new Texture(textureFile));
}
DirectImageResolver imageResolver = new DirectImageResolver(textures);
TiledMap map = loadMap(root, tideFile, imageResolver);
map.setOwnedResources(textures.values().toArray());
return map;
} catch (IOException e) {
throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
}
}
use of com.badlogic.gdx.maps.ImageResolver.DirectImageResolver in project libgdx by libgdx.
the class TmxMapLoader method load.
/** Loads the {@link TiledMap} from the given file. The file is resolved via the {@link FileHandleResolver} set in the
* constructor of this class. By default it will resolve to an internal file.
* @param fileName the filename
* @param parameters specifies whether to use y-up, generate mip maps etc.
* @return the TiledMap */
public TiledMap load(String fileName, TmxMapLoader.Parameters parameters) {
try {
this.convertObjectToTileSpace = parameters.convertObjectToTileSpace;
this.flipY = parameters.flipY;
FileHandle tmxFile = resolve(fileName);
root = xml.parse(tmxFile);
ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>();
Array<FileHandle> textureFiles = loadTilesets(root, tmxFile);
textureFiles.addAll(loadImages(root, tmxFile));
for (FileHandle textureFile : textureFiles) {
Texture texture = new Texture(textureFile, parameters.generateMipMaps);
texture.setFilter(parameters.textureMinFilter, parameters.textureMagFilter);
textures.put(textureFile.path(), texture);
}
DirectImageResolver imageResolver = new DirectImageResolver(textures);
TiledMap map = loadTilemap(root, tmxFile, imageResolver);
map.setOwnedResources(textures.values().toArray());
return map;
} catch (IOException e) {
throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e);
}
}
Aggregations