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

public abstract Class BaseTmjMapLoader<P extends BaseTiledMapLoader.Parameters>

extends BaseTiledMapLoader<P extends BaseTiledMapLoader.Parameters>
Class Inheritance
Known Direct Subclasses
com.badlogic.gdx.maps.tiled.TmjMapLoader, com.badlogic.gdx.maps.tiled.AtlasTmjMapLoader
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, .JsonReader, .JsonValue, .ObjectMap, .ObjectIntMap, .SerializationException, .StreamUtils, java.io.BufferedInputStream, .ByteArrayInputStream, .IOException, .InputStream, java.util.zip.GZIPInputStream, .InflaterInputStream

Field Summary

Modifier and TypeField and Description
protected JsonReader
protected JsonValue
protected ObjectMap<String, JsonValue>
protected ObjectIntMap<String>
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 tmjFile, ImageResolver imageResolver, TiledMapTileSet tileSet, JsonValue element, JsonValue tiles, String name, int firstgid, int tilewidth, int tileheight, int spacing, int margin, int offsetX, int offsetY, String imageSource, int imageWidth, int imageHeight, FileHandle image)

private void
private void
protected JsonValue
cloneElementShallow(JsonValue src)

Returns a shallow copy of the source JsonValue element we pass in. This method only copies the basic type and value (string, number, boolean, or null) from the source element.

protected AnimatedTiledMapTile
createAnimatedTile(TiledMapTileSet tileSet, TiledMapTile tile, JsonValue tileElement, int firstgid)

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

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

Returns the assets this asset requires to be loaded first.

public static int[]
getTileIds(JsonValue element, int width, int height)

protected void
protected void
loadImageLayer(TiledMap map, MapLayers parentLayers, JsonValue element, FileHandle tmjFile, ImageResolver imageResolver)

protected void
loadLayer(TiledMap map, MapLayers parentLayers, JsonValue element, FileHandle tmjFile, ImageResolver imageResolver)

protected void
loadLayerGroup(TiledMap map, MapLayers parentLayers, JsonValue element, FileHandle tmjFile, ImageResolver imageResolver)

protected void
loadObject(TiledMap map, MapLayer layer, JsonValue element)

protected void
protected void
loadObject(TiledMap map, MapObjects objects, JsonValue element, float heightInPixels)

protected void
loadObjectGroup(TiledMap map, MapLayers parentLayers, JsonValue element, FileHandle tmjFile)

private void
loadProperties(final MapProperties properties, JsonValue element)

protected TiledMap

Returns:

the TiledMap
loadTiledMap
(FileHandle
the Filehandle of the tmj file
tmjFile
,
P parameter, ImageResolver imageResolver)

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

Loads the map data, given the JSON root element

protected void
loadTileLayer(TiledMap map, MapLayers parentLayers, JsonValue element)

public TiledMapTileSet
loadTileSet(JsonValue rawElement, FileHandle tmjFile, ImageResolver imageResolver)

protected JsonValue
mergeJsonObject(JsonValue parentObject, JsonValue templateObject)

JSON TextMapObjects contain object nodes containing specific text related attributes.

protected JsonValue
mergeJsonProperties(JsonValue parentProps, JsonValue templateProps)

Merges two properties arrays from a parent and template.

protected JsonValue
mergeParentElementWithTemplate(JsonValue parent, JsonValue template)

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

protected JsonValue

Returns:

a merged JsonValue representing the combined JsonValues.
resolveTemplateObject
(JsonValue
JsonValue which contains the single json element we are currently parsing
mapElement
,
FileHandle
tmjFile
tmjFile
)

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

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

Field Detail

jsonback to summary
protected JsonReader json
rootback to summary
protected JsonValue root
templateCacheback to summary
protected ObjectMap<String, JsonValue> templateCache
tilesetPathsToGIDsback to summary
protected ObjectIntMap<String> tilesetPathsToGIDs

Constructor Detail

BaseTmjMapLoaderback to summary
public BaseTmjMapLoader(FileHandleResolver resolver)

Method Detail

addStaticTilesback to summary
protected abstract void addStaticTiles(FileHandle tmjFile, ImageResolver imageResolver, TiledMapTileSet tileSet, JsonValue element, JsonValue tiles, 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
private void addTileObjectGroup(TiledMapTile tile, JsonValue tileElement)
addTilePropertiesback to summary
private void addTileProperties(TiledMapTile tile, JsonValue tileElement)
cloneElementShallowback to summary
protected JsonValue cloneElementShallow(JsonValue src)

Returns a shallow copy of the source JsonValue element we pass in. This method only copies the basic type and value (string, number, boolean, or null) from the source element. It does not clone child element for arrays or objects. If the source element is an array or object, the entire element is copied using JsonValue's copy constructor, resulting in a deep copy for those types.

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

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

Loads the map data, given the JSON root element

Parameters
tmjFile:FileHandle

the Filehandle of the tmj file

Returns:TiledMap

the TiledMap

Annotations
@Override
loadTileLayerback to summary
protected void loadTileLayer(TiledMap map, MapLayers parentLayers, JsonValue element)
loadTileSetback to summary
public TiledMapTileSet loadTileSet(JsonValue rawElement, FileHandle tmjFile, ImageResolver imageResolver)
mergeJsonObjectback to summary
protected JsonValue mergeJsonObject(JsonValue parentObject, JsonValue templateObject)

JSON TextMapObjects contain object nodes containing specific text related attributes. Here we merge them, parent attributes will override those found in templates.

mergeJsonPropertiesback to summary
protected JsonValue mergeJsonProperties(JsonValue parentProps, JsonValue templateProps)

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

mergeParentElementWithTemplateback to summary
protected JsonValue mergeParentElementWithTemplate(JsonValue parent, JsonValue 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.

resolveTemplateObjectback to summary
protected JsonValue resolveTemplateObject(JsonValue mapElement, FileHandle tmjFile)

Method specifically meant to help resolve template object properties and attributes found in objectgroups. Each template object links to a specific .tj 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:JsonValue

JsonValue which contains the single json element we are currently parsing

tmjFile:FileHandle

tmjFile

Returns:JsonValue

a merged JsonValue representing the combined JsonValues.

resolveTilesetElementback to summary
private JsonValue resolveTilesetElement(JsonValue element, FileHandle tmjFile)
resolveTilesetImageback to summary
private FileHandle resolveTilesetImage(JsonValue element, FileHandle tmjFile)