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 class
BaseTmxMapLoader.Parameters
-
Field Summary
Fields Modifier and Type Field Description protected boolean
convertObjectToTileSpace
protected static int
FLAG_FLIP_DIAGONALLY
protected static int
FLAG_FLIP_HORIZONTALLY
protected static int
FLAG_FLIP_VERTICALLY
protected boolean
flipY
protected IntMap<MapObject>
idToObject
protected TiledMap
map
protected int
mapHeightInPixels
protected int
mapTileHeight
protected int
mapTileWidth
protected int
mapWidthInPixels
protected static int
MASK_CLEAR
protected XmlReader.Element
root
protected Array<java.lang.Runnable>
runOnEndOfLoadTiled
protected XmlReader
xml
-
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 void
addStaticTiledMapTile(TiledMapTileSet tileSet, TextureRegion textureRegion, int tileId, float offsetX, float offsetY)
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)
protected void
addTileObjectGroup(TiledMapTile tile, XmlReader.Element tileElement)
protected void
addTileProperties(TiledMapTile tile, XmlReader.Element tileElement)
protected java.lang.Object
castProperty(java.lang.String name, java.lang.String value, java.lang.String type)
protected AnimatedTiledMapTile
createAnimatedTile(TiledMapTileSet tileSet, TiledMapTile tile, XmlReader.Element tileElement, int firstgid)
protected TiledMapTileLayer.Cell
createTileLayerCell(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 theMapObject
instances.protected static FileHandle
getRelativeFileHandle(FileHandle file, java.lang.String path)
static int[]
getTileIds(XmlReader.Element element, int width, int height)
protected void
loadBasicLayerInfo(MapLayer layer, XmlReader.Element element)
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
loadObject(TiledMap map, MapLayer layer, XmlReader.Element element)
protected void
loadObject(TiledMap map, MapObjects objects, XmlReader.Element element, float heightInPixels)
protected void
loadObject(TiledMap map, TiledMapTile tile, XmlReader.Element element)
protected void
loadObjectGroup(TiledMap map, MapLayers parentLayers, XmlReader.Element element)
protected void
loadProperties(MapProperties properties, XmlReader.Element element)
protected TiledMap
loadTiledMap(FileHandle tmxFile, P parameter, ImageResolver imageResolver)
Loads the map data, given the XML root elementprotected void
loadTileLayer(TiledMap map, MapLayers parentLayers, XmlReader.Element element)
protected void
loadTileSet(XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
protected static int
unsignedByteToInt(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:AssetLoader
Returns the assets this asset requires to be loaded first. This method may be called on a thread other than the GL thread.- Specified by:
getDependencies
in 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 theMapObject
instances. 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)
-
-