APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.maps.tiled

public Class TiledMapLoader

extends AsynchronousAssetLoader<TiledMap, BaseTiledMapLoader.Parameters>
Class Inheritance
Imports
com.badlogic.gdx.assets.AssetDescriptor, .AssetManager, com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader, .FileHandleResolver, com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.utils.*

A universal map loader that automatically delegates to the appropriate underlying map loader TmxMapLoader, AtlasTmxMapLoader, TmjMapLoader, or AtlasTmjMapLoader based solely on the map file's extension and content. A primary use case is for projects that need to load a mix of TMX and TMJ maps (with or without atlases) using a single loader instance inside an AssetManager. For TMX and TMJ files, this loader checks for the presence of an "atlas" property. If found, it uses an atlas-based loader; otherwise, it falls back to the standard loader.

Field Summary

Modifier and TypeField and Description
private final AtlasTmjMapLoader
private final AtlasTmxMapLoader
private final JsonReader
private final TmjMapLoader
private final TmxMapLoader
private final XmlReader

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Array<AssetDescriptor<T>>
getDependencies(String fileName, FileHandle file, BaseTiledMapLoader.Parameters parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AssetLoader.getDependencies.

Returns the assets this asset requires to be loaded first.

public TiledMap

Returns:

a loaded TiledMap
load
(String
path to a .tmx or .tmj file
fileName
)

Universal synchronous loader.

public TiledMap

Returns:

a loaded TiledMap
load
(String
path to a .tmx or .tmj file
fileName
,
BaseTiledMapLoader.Parameters
existing Parameters object
parameter
)

Universal synchronous loader with custom parameters.

public void
loadAsync(AssetManager manager, String fileName, FileHandle file, BaseTiledMapLoader.Parameters parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadAsync.

Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.

public TiledMap
loadSync(AssetManager manager, String fileName, FileHandle file, BaseTiledMapLoader.Parameters parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadSync.

Loads the OpenGL part of the asset.

private boolean
Inherited from com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader:
unloadAsync

Field Detail

atlasTmjMapLoaderback to summary
private final AtlasTmjMapLoader atlasTmjMapLoader
atlasTmxMapLoaderback to summary
private final AtlasTmxMapLoader atlasTmxMapLoader
jsonReaderback to summary
private final JsonReader jsonReader
tmjMapLoaderback to summary
private final TmjMapLoader tmjMapLoader
tmxMapLoaderback to summary
private final TmxMapLoader tmxMapLoader
xmlReaderback to summary
private final XmlReader xmlReader

Constructor Detail

TiledMapLoaderback to summary
public TiledMapLoader()
TiledMapLoaderback to summary
public TiledMapLoader(FileHandleResolver resolver)

Method Detail

getDependenciesback to summary
public Array<AssetDescriptor<T>> getDependencies(String fileName, FileHandle file, BaseTiledMapLoader.Parameters parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AssetLoader.getDependencies.

Doc from com.badlogic.gdx.assets.loaders.AssetLoader.getDependencies.

Returns the assets this asset requires to be loaded first. This method may be called on a thread other than the GL thread.

Annotations
@Override
loadback to summary
public TiledMap load(String fileName)

Universal synchronous loader. This method is a thin wrapper that picks the correct underlying loader (TMX vs TMJ, atlas vs non‑atlas) and then delegates straight through to its synchronous load(...) implementation.

Parameters
fileName:String

path to a .tmx or .tmj file

Returns:TiledMap

a loaded TiledMap

Exceptions
GdxRuntimeException:
on unsupported formats or parse errors
loadback to summary
public TiledMap load(String fileName, BaseTiledMapLoader.Parameters parameter)

Universal synchronous loader with custom parameters. Resolves the file and Inspects the extension (tmx vs tmj). Check whether the ‘atlas’ property exists in the map and delegates to the appropriate loader’s load(...).

Parameters
fileName:String

path to a .tmx or .tmj file

parameter:BaseTiledMapLoader.Parameters

existing Parameters object

Returns:TiledMap

a loaded TiledMap

Exceptions
GdxRuntimeException:
on unsupported formats or parse errors
loadAsyncback to summary
public void loadAsync(AssetManager manager, String fileName, FileHandle file, BaseTiledMapLoader.Parameters parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadAsync.

Doc from com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadAsync.

Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.

Annotations
@Override
loadSyncback to summary
public TiledMap loadSync(AssetManager manager, String fileName, FileHandle file, BaseTiledMapLoader.Parameters parameter)

Implements abstract com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadSync.

Doc from com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader.loadSync.

Loads the OpenGL part of the asset.

Annotations
@Override
usesAtlasback to summary
private boolean usesAtlas(FileHandle file)