public class TmxMapLoader extends AsynchronousAssetLoader<TiledMap,TmxMapLoader.Parameters>
Modifier and Type | Class and Description |
---|---|
static class |
TmxMapLoader.Parameters |
Modifier and Type | Field and Description |
---|---|
protected static int |
FLAG_FLIP_DIAGONALLY |
protected static int |
FLAG_FLIP_HORIZONTALLY |
protected static int |
FLAG_FLIP_VERTICALLY |
protected TiledMap |
map |
protected int |
mapHeightInPixels |
protected int |
mapWidthInPixels |
protected static int |
MASK_CLEAR |
protected XmlReader.Element |
root |
protected XmlReader |
xml |
protected boolean |
yUp |
Constructor and Description |
---|
TmxMapLoader() |
TmxMapLoader(FileHandleResolver resolver)
Creates loader
|
Modifier and Type | Method and Description |
---|---|
protected TiledMapTileLayer.Cell |
createTileLayerCell(boolean flipHorizontally,
boolean flipVertically,
boolean flipDiagonally) |
Array<AssetDescriptor> |
getDependencies(java.lang.String fileName,
FileHandle tmxFile,
TmxMapLoader.Parameters parameter)
Retrieves TiledMap resource dependencies
|
protected static FileHandle |
getRelativeFileHandle(FileHandle file,
java.lang.String path) |
TiledMap |
load(java.lang.String fileName)
Loads the
TiledMap from the given file. |
TiledMap |
load(java.lang.String fileName,
TmxMapLoader.Parameters parameters)
Loads the
TiledMap from the given file. |
void |
loadAsync(AssetManager manager,
java.lang.String fileName,
FileHandle tmxFile,
TmxMapLoader.Parameters parameter)
Loads the non-OpenGL part of the asset and injects any dependencies of the asset into the AssetManager.
|
protected void |
loadObject(MapLayer layer,
XmlReader.Element element) |
protected void |
loadObjectGroup(TiledMap map,
XmlReader.Element element) |
protected void |
loadProperties(MapProperties properties,
XmlReader.Element element) |
TiledMap |
loadSync(AssetManager manager,
java.lang.String fileName,
FileHandle file,
TmxMapLoader.Parameters parameter)
Loads the OpenGL part of the asset.
|
protected void |
loadTileLayer(TiledMap map,
XmlReader.Element element)
Load one layer (a 'layer' tag).
|
protected TiledMap |
loadTilemap(XmlReader.Element root,
FileHandle tmxFile,
ImageResolver imageResolver)
Loads the map data, given the XML root element and an
ImageResolver used to return the tileset Textures |
protected void |
loadTileSet(TiledMap map,
XmlReader.Element element,
FileHandle tmxFile,
ImageResolver imageResolver)
Loads the specified tileset data, adding it to the collection of the specified map, given the XML element, the tmxFile and
an
ImageResolver used to retrieve the tileset Textures. |
protected Array<FileHandle> |
loadTilesets(XmlReader.Element root,
FileHandle tmxFile)
Loads the tilesets
|
protected static int |
unsignedByteToInt(byte b) |
resolve
protected static final int FLAG_FLIP_HORIZONTALLY
protected static final int FLAG_FLIP_VERTICALLY
protected static final int FLAG_FLIP_DIAGONALLY
protected static final int MASK_CLEAR
protected XmlReader xml
protected XmlReader.Element root
protected boolean yUp
protected int mapWidthInPixels
protected int mapHeightInPixels
protected TiledMap map
public TmxMapLoader()
public TmxMapLoader(FileHandleResolver resolver)
resolver
- public TiledMap load(java.lang.String fileName)
TiledMap
from the given file. The file is resolved via the FileHandleResolver
set in the
constructor of this class. By default it will resolve to an internal file. The map will be loaded for a y-up coordinate
system.fileName
- the filenamepublic TiledMap load(java.lang.String fileName, TmxMapLoader.Parameters parameters)
TiledMap
from the given file. The file is resolved via the FileHandleResolver
set in the
constructor of this class. By default it will resolve to an internal file.fileName
- the filenameparameters
- specifies whether to use y-up, generate mip maps etc.public void loadAsync(AssetManager manager, java.lang.String fileName, FileHandle tmxFile, TmxMapLoader.Parameters parameter)
AsynchronousAssetLoader
loadAsync
in class AsynchronousAssetLoader<TiledMap,TmxMapLoader.Parameters>
fileName
- the name of the asset to loadtmxFile
- the resolved file to loadparameter
- the parameters to use for loading the assetpublic TiledMap loadSync(AssetManager manager, java.lang.String fileName, FileHandle file, TmxMapLoader.Parameters parameter)
AsynchronousAssetLoader
loadSync
in class AsynchronousAssetLoader<TiledMap,TmxMapLoader.Parameters>
file
- the resolved file to loadpublic Array<AssetDescriptor> getDependencies(java.lang.String fileName, FileHandle tmxFile, TmxMapLoader.Parameters parameter)
getDependencies
in class AssetLoader<TiledMap,TmxMapLoader.Parameters>
fileName
- parameter
- not used for nowtmxFile
- the resolved file to loadprotected TiledMap loadTilemap(XmlReader.Element root, FileHandle tmxFile, ImageResolver imageResolver)
ImageResolver
used to return the tileset Texturesroot
- the XML root elementtmxFile
- the Filehandle of the tmx fileimageResolver
- the ImageResolver
TiledMap
protected Array<FileHandle> loadTilesets(XmlReader.Element root, FileHandle tmxFile) throws java.io.IOException
root
- the root XML elementjava.io.IOException
protected void loadTileSet(TiledMap map, XmlReader.Element element, FileHandle tmxFile, ImageResolver imageResolver)
ImageResolver
used to retrieve the tileset Textures.
Default tileset's property keys that are loaded by default are:
The values are extracted from the specified Tmx file, if a value can't be found then the default is used.
map
- the Map whose tilesets collection will be populatedelement
- the XML element identifying the tileset to loadtmxFile
- the Filehandle of the tmx fileimageResolver
- the ImageResolver
protected void loadTileLayer(TiledMap map, XmlReader.Element element)
map
- element
- protected void loadObjectGroup(TiledMap map, XmlReader.Element element)
protected void loadObject(MapLayer layer, XmlReader.Element element)
protected void loadProperties(MapProperties properties, XmlReader.Element element)
protected TiledMapTileLayer.Cell createTileLayerCell(boolean flipHorizontally, boolean flipVertically, boolean flipDiagonally)
protected static FileHandle getRelativeFileHandle(FileHandle file, java.lang.String path)
protected static int unsignedByteToInt(byte b)