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

public abstract Class BaseTmxMapLoader<P extends BaseTiledMapLoader.Parameters>

extends BaseTiledMapLoader<P extends BaseTiledMapLoader.Parameters>
Class Inheritance
Known Direct Subclasses
com.badlogic.gdx.maps.tiled.TmxMapLoader, com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader
Imports
com.badlogic.gdx.assets.AssetDescriptor, com.badlogic.gdx.assets.loaders.FileHandleResolver, .TextureLoader, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.graphics.Color, com.badlogic.gdx.graphics.g2d.TextureRegion, com.badlogic.gdx.maps.ImageResolver, .MapGroupLayer, .MapLayer, .MapLayers, .MapObject, .MapObjects, .MapProperties, com.badlogic.gdx.maps.objects.EllipseMapObject, .PointMapObject, .PolygonMapObject, .PolylineMapObject, .RectangleMapObject, .TextMapObject, com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell, com.badlogic.gdx.maps.tiled.objects.TiledMapTileMapObject, com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile, .StaticTiledMapTile, com.badlogic.gdx.math.Polygon, .Polyline, com.badlogic.gdx.utils.Array, .Base64Coder, .GdxRuntimeException, .IntArray, .IntMap, .ObjectMap, .ObjectIntMap, .ObjectSet, .SerializationException, .StreamUtils, .XmlReader, .XmlReader.Element, java.io.BufferedInputStream, .ByteArrayInputStream, .IOException, .InputStream, java.util.zip.GZIPInputStream, .InflaterInputStream

Field Summary

Modifier and TypeField and Description
protected XmlReader.Element
protected ObjectMap<String, XmlReader.Element>
protected ObjectIntMap<String>
protected XmlReader
Inherited from com.badlogic.gdx.maps.tiled.BaseTiledMapLoader:
convertObjectToTileSpaceFLAG_FLIP_DIAGONALLYFLAG_FLIP_HORIZONTALLYFLAG_FLIP_VERTICALLYflipYidToObjectmapmapHeightInPixelsmapTileHeightmapTileWidthmapWidthInPixelsMASK_CLEARprojectClassInforunOnEndOfLoadTiled

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract void
addStaticTiles(FileHandle tmxFile, ImageResolver imageResolver, TiledMapTileSet tileset, XmlReader.Element element, Array<XmlReader.Element> tileElements, String name, int firstgid, int tilewidth, int tileheight, int spacing, int margin, int offsetX, int offsetY, String imageSource, int imageWidth, int imageHeight, FileHandle image)

protected void
protected void
protected XmlReader.Element
cloneElementShallow(XmlReader.Element sourceElement)

Returns a shallow copy of the source element we pass in.

protected AnimatedTiledMapTile
createAnimatedTile(TiledMapTileSet tileSet, TiledMapTile tile, XmlReader.Element tileElement, int firstgid)

public Array<AssetDescriptor<T>>
getDependencies(String fileName, FileHandle tmxFile, P parameter)

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

Returns the assets this asset requires to be loaded first.

protected XmlReader.Element
getPropertyByName(XmlReader.Element classElement, String propName)

private static String
public static int[]
getTileIds(XmlReader.Element element, int width, int height)

protected void
protected void
loadClassProperties(String className, MapProperties classProperties, XmlReader.Element classElement)

protected void
loadImageLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)

protected void
loadLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)

protected void
loadLayerGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)

protected void
protected void
protected void
loadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels)

protected void
loadObjectGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile)

protected void
loadProperties(final MapProperties properties, XmlReader.Element element)

protected TiledMap

Returns:

the TiledMap
loadTiledMap
(FileHandle
the Filehandle of the tmx file
tmxFile
,
P parameter, ImageResolver imageResolver)

Implements abstract com.badlogic.gdx.maps.tiled.BaseTiledMapLoader.loadTiledMap.

Loads the map data, given the XML root element

protected void
loadTileLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element)

public TiledMapTileSet
loadTileSet(XmlReader.Element tilesetElementRaw, FileHandle tmxFile, ImageResolver imageResolver)

protected XmlReader.Element
mergeParentElementWithTemplate(XmlReader.Element parent, XmlReader.Element template)

Recursively merges a “parent” (map) object element with its referenced template object element.

protected XmlReader.Element
mergeProperties(XmlReader.Element parentProps, XmlReader.Element templateProps)

Merges two <properties> tags from a parent and template.

protected XmlReader.Element

Returns:

a merged Element representing the combined elements.
resolveTemplateObject
(XmlReader.Element
Element which contains the single xml element we are currently parsing
mapElement
,
FileHandle
tmxFile
tmxFile
)

Method specifically meant to help resolve template object properties and attributes found in objectgroups.

private XmlReader.Element
private FileHandle
Inherited from com.badlogic.gdx.maps.tiled.BaseTiledMapLoader:
addStaticTiledMapTilecastPropertycreateTileLayerCellgetDependencyAssetDescriptorsgetIdToObjectgetRelativeFileHandleloadBasicPropertyloadJsonClassPropertiesloadMapPropertiesClassDefaultsloadObjectPropertyloadProjectFiletiledColorToLibGDXColorunsignedByteToInt

Field Detail

rootback to summary
protected XmlReader.Element root
templateCacheback to summary
protected ObjectMap<String, XmlReader.Element> templateCache
tilesetPathsToGIDsback to summary
protected ObjectIntMap<String> tilesetPathsToGIDs
xmlback to summary
protected XmlReader xml

Constructor Detail

BaseTmxMapLoaderback to summary
public BaseTmxMapLoader(FileHandleResolver resolver)

Method Detail

addStaticTilesback to summary
protected abstract void addStaticTiles(FileHandle tmxFile, ImageResolver imageResolver, TiledMapTileSet tileset, XmlReader.Element element, Array<XmlReader.Element> tileElements, String name, int firstgid, int tilewidth, int tileheight, int spacing, int margin, int offsetX, int offsetY, String imageSource, int imageWidth, int imageHeight, FileHandle image)
addTileObjectGroupback to summary
protected void addTileObjectGroup(TiledMapTile tile, XmlReader.Element tileElement)
addTilePropertiesback to summary
protected void addTileProperties(TiledMapTile tile, XmlReader.Element tileElement)
cloneElementShallowback to summary
protected XmlReader.Element cloneElementShallow(XmlReader.Element sourceElement)

Returns a shallow copy of the source element we pass in.

createAnimatedTileback to summary
protected AnimatedTiledMapTile createAnimatedTile(TiledMapTileSet tileSet, TiledMapTile tile, XmlReader.Element tileElement, int firstgid)
getDependenciesback to summary
public Array<AssetDescriptor<T>> getDependencies(String fileName, FileHandle tmxFile, P 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
getPropertyByNameback to summary
protected XmlReader.Element getPropertyByName(XmlReader.Element classElement, String propName)
getPropertyValueback to summary
private static String getPropertyValue(XmlReader.Element classProp)
getTileIdsback to summary
public static int[] getTileIds(XmlReader.Element element, int width, int height)
loadBasicLayerInfoback to summary
protected void loadBasicLayerInfo(MapLayer layer, XmlReader.Element element)
loadClassPropertiesback to summary
protected void loadClassProperties(String className, MapProperties classProperties, XmlReader.Element classElement)
loadImageLayerback to summary
protected void loadImageLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
loadLayerback to summary
protected void loadLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
loadLayerGroupback to summary
protected void loadLayerGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
loadObjectback to summary
protected void loadObject(TiledMap map, MapLayer layer, XmlReader.Element element)
loadObjectback to summary
protected void loadObject(TiledMap map, TiledMapTile tile, XmlReader.Element element)
loadObjectback to summary
protected void loadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels)
loadObjectGroupback to summary
protected void loadObjectGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile)
loadPropertiesback to summary
protected void loadProperties(final MapProperties properties, XmlReader.Element element)
loadTiledMapback to summary
protected TiledMap loadTiledMap(FileHandle tmxFile, P parameter, ImageResolver imageResolver)

Implements abstract com.badlogic.gdx.maps.tiled.BaseTiledMapLoader.loadTiledMap.

Loads the map data, given the XML root element

Parameters
tmxFile:FileHandle

the Filehandle of the tmx file

Returns:TiledMap

the TiledMap

Annotations
@Override
loadTileLayerback to summary
protected void loadTileLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element)
loadTileSetback to summary
public TiledMapTileSet loadTileSet(XmlReader.Element tilesetElementRaw, FileHandle tmxFile, ImageResolver imageResolver)
mergeParentElementWithTemplateback to summary
protected XmlReader.Element mergeParentElementWithTemplate(XmlReader.Element parent, XmlReader.Element template)

Recursively merges a “parent” (map) object element with its referenced template object element. Attributes and properties found in the template are allowed to be overwritten by any matching ones found in its parent element. The returned element is a new detached tree (parent = null) so it can be handed straight to the loadObject() method without issues.

mergePropertiesback to summary
protected XmlReader.Element mergeProperties(XmlReader.Element parentProps, XmlReader.Element templateProps)

Merges two tags from a parent and template. Matching properties from the parent will override the template's.

resolveTemplateObjectback to summary
protected XmlReader.Element resolveTemplateObject(XmlReader.Element mapElement, FileHandle tmxFile)

Method specifically meant to help resolve template object properties and attributes found in objectgroups. Each template object links to a specific .tx file. Attributes and properties found in the template are allowed to be overwritten by any matching ones found in its parent element. Knowing this, we will merge the two elements together with the parent's props taking precedence and then return the merged value.

Parameters
mapElement:XmlReader.Element

Element which contains the single xml element we are currently parsing

tmxFile:FileHandle

tmxFile

Returns:XmlReader.Element

a merged Element representing the combined elements.

resolveTilesetElementback to summary
private XmlReader.Element resolveTilesetElement(XmlReader.Element tilesetElement, FileHandle tmxFile)
resolveTilesetImageback to summary
private FileHandle resolveTilesetImage(XmlReader.Element tilesetElement, FileHandle tmxFile)