Package com.badlogic.gdx.maps.tiled
Class BaseTmxMapLoader<P extends BaseTmxMapLoader.Parameters>
- java.lang.Object
-
- com.badlogic.gdx.assets.loaders.AssetLoader<T,P>
-
- com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader<TiledMap,P>
-
- com.badlogic.gdx.maps.tiled.BaseTmxMapLoader<P>
-
- Direct Known Subclasses:
AtlasTmxMapLoader,TmxMapLoader
public abstract class BaseTmxMapLoader<P extends BaseTmxMapLoader.Parameters> extends AsynchronousAssetLoader<TiledMap,P>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseTmxMapLoader.Parameters
-
Field Summary
Fields Modifier and Type Field Description protected booleanconvertObjectToTileSpaceprotected static intFLAG_FLIP_DIAGONALLYprotected static intFLAG_FLIP_HORIZONTALLYprotected static intFLAG_FLIP_VERTICALLYprotected booleanflipYprotected IntMap<MapObject>idToObjectprotected TiledMapmapprotected intmapHeightInPixelsprotected intmapTileHeightprotected intmapTileWidthprotected intmapWidthInPixelsprotected static intMASK_CLEARprotected XmlReader.Elementrootprotected Array<java.lang.Runnable>runOnEndOfLoadTiledprotected XmlReaderxml
-
Constructor Summary
Constructors Constructor Description BaseTmxMapLoader(FileHandleResolver resolver)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddStaticTiledMapTile(TiledMapTileSet tileSet, TextureRegion textureRegion, int tileId, float offsetX, float offsetY)protected abstract voidaddStaticTiles(FileHandle tmxFile, ImageResolver imageResolver, TiledMapTileSet tileset, XmlReader.Element element, Array<XmlReader.Element> tileElements, java.lang.String name, int firstgid, int tilewidth, int tileheight, int spacing, int margin, java.lang.String source, int offsetX, int offsetY, java.lang.String imageSource, int imageWidth, int imageHeight, FileHandle image)protected voidaddTileObjectGroup(TiledMapTile tile, XmlReader.Element tileElement)protected voidaddTileProperties(TiledMapTile tile, XmlReader.Element tileElement)protected java.lang.ObjectcastProperty(java.lang.String name, java.lang.String value, java.lang.String type)protected AnimatedTiledMapTilecreateAnimatedTile(TiledMapTileSet tileSet, TiledMapTile tile, XmlReader.Element tileElement, int firstgid)protected TiledMapTileLayer.CellcreateTileLayerCell(boolean flipHorizontally, boolean flipVertically, boolean flipDiagonally)Array<AssetDescriptor>getDependencies(java.lang.String fileName, FileHandle tmxFile, P parameter)Returns the assets this asset requires to be loaded first.protected abstract Array<AssetDescriptor>getDependencyAssetDescriptors(FileHandle tmxFile, TextureLoader.TextureParameter textureParameter)IntMap<MapObject>getIdToObject()Gets a map of the object ids to theMapObjectinstances.protected static FileHandlegetRelativeFileHandle(FileHandle file, java.lang.String path)static int[]getTileIds(XmlReader.Element element, int width, int height)protected voidloadBasicLayerInfo(MapLayer layer, XmlReader.Element element)protected voidloadImageLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)protected voidloadLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)protected voidloadLayerGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)protected voidloadObject(TiledMap map, MapLayer layer, XmlReader.Element element)protected voidloadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels)protected voidloadObject(TiledMap map, TiledMapTile tile, XmlReader.Element element)protected voidloadObjectGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element)protected voidloadProperties(MapProperties properties, XmlReader.Element element)protected TiledMaploadTiledMap(FileHandle tmxFile, P parameter, ImageResolver imageResolver)Loads the map data, given the XML root elementprotected voidloadTileLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element)protected voidloadTileSet(XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)protected static intunsignedByteToInt(byte b)-
Methods inherited from class com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader
loadAsync, loadSync, unloadAsync
-
Methods inherited from class com.badlogic.gdx.assets.loaders.AssetLoader
resolve
-
-
-
-
Field Detail
-
FLAG_FLIP_HORIZONTALLY
protected static final int FLAG_FLIP_HORIZONTALLY
- See Also:
- Constant Field Values
-
FLAG_FLIP_VERTICALLY
protected static final int FLAG_FLIP_VERTICALLY
- See Also:
- Constant Field Values
-
FLAG_FLIP_DIAGONALLY
protected static final int FLAG_FLIP_DIAGONALLY
- See Also:
- Constant Field Values
-
MASK_CLEAR
protected static final int MASK_CLEAR
- See Also:
- Constant Field Values
-
xml
protected XmlReader xml
-
root
protected XmlReader.Element root
-
convertObjectToTileSpace
protected boolean convertObjectToTileSpace
-
flipY
protected boolean flipY
-
mapTileWidth
protected int mapTileWidth
-
mapTileHeight
protected int mapTileHeight
-
mapWidthInPixels
protected int mapWidthInPixels
-
mapHeightInPixels
protected int mapHeightInPixels
-
map
protected TiledMap map
-
runOnEndOfLoadTiled
protected Array<java.lang.Runnable> runOnEndOfLoadTiled
-
-
Constructor Detail
-
BaseTmxMapLoader
public BaseTmxMapLoader(FileHandleResolver resolver)
-
-
Method Detail
-
getDependencies
public Array<AssetDescriptor> getDependencies(java.lang.String fileName, FileHandle tmxFile, P parameter)
Description copied from class:AssetLoaderReturns the assets this asset requires to be loaded first. This method may be called on a thread other than the GL thread.- Specified by:
getDependenciesin classAssetLoader<TiledMap,P extends BaseTmxMapLoader.Parameters>- Parameters:
fileName- name of the asset to loadtmxFile- the resolved file to loadparameter- parameters for loading the asset- Returns:
- other assets that the asset depends on and need to be loaded first or null if there are no dependencies.
-
getIdToObject
@Null public IntMap<MapObject> getIdToObject()
Gets a map of the object ids to theMapObjectinstances. Returns null ifloadTiledMap(FileHandle, Parameters, ImageResolver)has not been called yet.- Returns:
- the map of the ids to
MapObject, or null ifloadTiledMap(FileHandle, Parameters, ImageResolver)method has not been called yet.
-
getDependencyAssetDescriptors
protected abstract Array<AssetDescriptor> getDependencyAssetDescriptors(FileHandle tmxFile, TextureLoader.TextureParameter textureParameter)
-
loadTiledMap
protected TiledMap loadTiledMap(FileHandle tmxFile, P parameter, ImageResolver imageResolver)
Loads the map data, given the XML root element- Parameters:
tmxFile- the Filehandle of the tmx fileparameter-imageResolver-- Returns:
- the
TiledMap
-
loadLayer
protected void loadLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
-
loadLayerGroup
protected void loadLayerGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
-
loadTileLayer
protected void loadTileLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element)
-
loadObjectGroup
protected void loadObjectGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element)
-
loadImageLayer
protected void loadImageLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
-
loadBasicLayerInfo
protected void loadBasicLayerInfo(MapLayer layer, XmlReader.Element element)
-
loadObject
protected void loadObject(TiledMap map, MapLayer layer, XmlReader.Element element)
-
loadObject
protected void loadObject(TiledMap map, TiledMapTile tile, XmlReader.Element element)
-
loadObject
protected void loadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels)
-
loadProperties
protected void loadProperties(MapProperties properties, XmlReader.Element element)
-
castProperty
protected java.lang.Object castProperty(java.lang.String name, java.lang.String value, java.lang.String type)
-
createTileLayerCell
protected TiledMapTileLayer.Cell createTileLayerCell(boolean flipHorizontally, boolean flipVertically, boolean flipDiagonally)
-
getTileIds
public static int[] getTileIds(XmlReader.Element element, int width, int height)
-
unsignedByteToInt
protected static int unsignedByteToInt(byte b)
-
getRelativeFileHandle
protected static FileHandle getRelativeFileHandle(FileHandle file, java.lang.String path)
-
loadTileSet
protected void loadTileSet(XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
-
addStaticTiles
protected abstract void addStaticTiles(FileHandle tmxFile, ImageResolver imageResolver, TiledMapTileSet tileset, XmlReader.Element element, Array<XmlReader.Element> tileElements, java.lang.String name, int firstgid, int tilewidth, int tileheight, int spacing, int margin, java.lang.String source, int offsetX, int offsetY, java.lang.String imageSource, int imageWidth, int imageHeight, FileHandle image)
-
addTileProperties
protected void addTileProperties(TiledMapTile tile, XmlReader.Element tileElement)
-
addTileObjectGroup
protected void addTileObjectGroup(TiledMapTile tile, XmlReader.Element tileElement)
-
createAnimatedTile
protected AnimatedTiledMapTile createAnimatedTile(TiledMapTileSet tileSet, TiledMapTile tile, XmlReader.Element tileElement, int firstgid)
-
addStaticTiledMapTile
protected void addStaticTiledMapTile(TiledMapTileSet tileSet, TextureRegion textureRegion, int tileId, float offsetX, float offsetY)
-
-