public class TiledMapData extends java.lang.Object implements TiledParserListener
| Modifier and Type | Field and Description |
|---|---|
protected FileHandle |
fileHandle |
protected org.mini2Dx.gdx.utils.Array<Layer> |
layers |
static long |
MAX_TILESET_LOAD_TIMESLICE_MILLIS |
protected org.mini2Dx.gdx.utils.ObjectMap<java.lang.String,TiledObjectGroup> |
objectGroups |
protected org.mini2Dx.gdx.utils.IntSet |
tilesetGids |
protected org.mini2Dx.gdx.utils.Array<Tileset> |
tilesets |
| Constructor and Description |
|---|
TiledMapData(FileHandle fileHandle) |
TiledMapData(TiledParser tiledParser,
FileHandle fileHandle) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsAnimatedTiles()
Returns if this map contains animated tiles
|
boolean |
containsProperty(java.lang.String propertyName)
Returns if the map contains the specified property
|
void |
dispose()
Releases any resources used by this TiledMap including tilesets
|
void |
dispose(boolean disposeTilesets)
Releases any resources used by this TiledMap
|
org.mini2Dx.gdx.utils.Array<Tile> |
getAnimatedTiles() |
Color |
getBackgroundColor()
Returns the background
Color of the map |
org.mini2Dx.gdx.utils.Array<AssetDescriptor> |
getDependencies() |
FileHandle |
getFileHandle()
Returns the
FileHandle for this data |
static GroupLayer |
getGroupLayer(org.mini2Dx.gdx.utils.Array<Layer> layers,
java.lang.String name,
boolean recursive)
Returns the
GroupLayer with the given name |
GroupLayer |
getGroupLayer(int index)
Returns the
GroupLayer at the given index |
GroupLayer |
getGroupLayer(java.lang.String name)
Returns the
GroupLayer with the given name |
GroupLayer |
getGroupLayer(java.lang.String name,
boolean recursive)
Returns the
GroupLayer with the given name |
int |
getHeight()
Returns the height of the map in tiles
|
int |
getLayerIndex(java.lang.String name)
Returns the index of the
TileLayer or TiledObjectGroup
with the given name |
int |
getLayerIndexIgnoreCase(java.lang.String name)
Returns the index of the
TileLayer or TiledObjectGroup
with the given name ignoring upper/lowercase differences |
org.mini2Dx.gdx.utils.Array<Layer> |
getLayers()
Returns the
Layers of this map |
static TiledObjectGroup |
getObjectGroup(org.mini2Dx.gdx.utils.Array<Layer> layers,
org.mini2Dx.gdx.utils.ObjectMap<java.lang.String,TiledObjectGroup> objectGroups,
java.lang.String name,
boolean recursive)
Returns the
TiledObjectGroup with the given name |
TiledObjectGroup |
getObjectGroup(java.lang.String name)
Returns the
TiledObjectGroup with the given name |
TiledObjectGroup |
getObjectGroup(java.lang.String name,
boolean recursive)
Returns the
TiledObjectGroup with the given name |
java.lang.Iterable<TiledObjectGroup> |
getObjectGroups()
Returns all the
TiledObjectGroups in this map |
Orientation |
getOrientation()
Returns the
Orientation of this map |
int |
getPixelHeight()
Return the height of the map in pixels
|
int |
getPixelWidth()
Returns the width of the map in pixels
|
java.lang.String |
getProperty(java.lang.String propertyName)
Returns the value of a specified property
|
int |
getSideLength()
Returns the stagger side length of this map
|
StaggerAxis |
getStaggerAxis()
Returns the
StaggerAxis of this map |
StaggerIndex |
getStaggerIndex()
Returns the
StaggerIndex of this map |
Tile |
getTile(int tileId)
Returns the
Tile for the given tile ID |
Tile |
getTile(int x,
int y,
int layer)
Returns the
Tile at the given coordinate on a specific layer |
int |
getTileHeight()
Returns the height of tiles in pixels
|
static TileLayer |
getTileLayer(org.mini2Dx.gdx.utils.Array<Layer> layers,
java.lang.String name,
boolean recursive)
Returns the
TileLayer with the given name |
TileLayer |
getTileLayer(int index)
Returns the
TileLayer at the given index |
TileLayer |
getTileLayer(java.lang.String name)
Returns the
TileLayer with the given name |
TileLayer |
getTileLayer(java.lang.String name,
boolean recursive)
Returns the
TileLayer with the given name |
org.mini2Dx.gdx.utils.Array<Tileset> |
getTilesets()
Returns the
Tilesets of this map |
int |
getTileWidth()
Returns the width of tiles in pixels
|
int |
getTotalLayers()
Returns the total amount of
Layer instances |
int |
getTotalObjectGroups()
Returns the total amount of
TiledObjectGroup instances |
int |
getWidth()
Returns the width of the map in tiles
|
boolean |
isTilesetTexturesLoaded()
Returns if the
Tileset images have been loaded |
boolean |
isTilesetTexturesLoaded(boolean ignoreObjectTemplateTilesets)
Returns if the
Tileset images have been loaded |
boolean |
loadTilesetTextures()
Loads all
Tileset textures for this map if they are not already loadedNote: Depending on the texture sizes, this may need to be called over several frames |
boolean |
loadTilesetTextures(AssetManager assetManager)
Loads all
Tileset textures for this map if they are not already loaded
Note: Depending on the texture sizes, this may need to be called over several frames |
boolean |
loadTilesetTextures(AssetManager assetManager,
boolean loadObjectTemplateTilesets)
Loads all
Tileset textures for this map if they are not already loaded
Note: Depending on the texture sizes, this may need to be called over several frames |
boolean |
loadTilesetTextures(boolean loadObjectTemplateTilesets)
Loads all
Tileset textures for this map if they are not already loaded
Note: Depending on the texture sizes, this may need to be called over several frames |
boolean |
loadTilesetTextures(TextureAtlas textureAtlas)
Loads all
Tileset textures for this map if they are not already loaded
Note: Depending on the texture sizes, this may need to be called over several frames |
boolean |
loadTilesetTextures(TextureAtlas textureAtlas,
boolean loadObjectTemplateTilesets)
Loads all
Tileset textures for this map if they are not already loaded
Note: Depending on the texture sizes, this may need to be called over several frames |
void |
onBeginParsing(java.lang.String orientation,
java.lang.String staggerAxis,
java.lang.String staggerIndex,
Color backgroundColor,
int width,
int height,
int tileWidth,
int tileHeight,
int sideLength) |
void |
onGroupLayerParsed(GroupLayer parsedLayer) |
void |
onMapPropertyParsed(java.lang.String propertyName,
java.lang.String value) |
void |
onObjectGroupParsed(TiledObjectGroup parsedObjectGroup) |
void |
onObjectTemplateParsed(TiledObjectTemplate parsedObjectTemplate) |
void |
onTileLayerParsed(TileLayer parsedLayer) |
void |
onTilePropertiesParsed(Tile tile) |
void |
onTilesetParsed(Tileset parsedTileset) |
void |
setProperty(java.lang.String propertyName,
java.lang.String value)
Sets the value of a specified property
|
public static long MAX_TILESET_LOAD_TIMESLICE_MILLIS
protected final FileHandle fileHandle
protected final org.mini2Dx.gdx.utils.Array<Tileset> tilesets
protected final org.mini2Dx.gdx.utils.IntSet tilesetGids
protected final org.mini2Dx.gdx.utils.Array<Layer> layers
protected final org.mini2Dx.gdx.utils.ObjectMap<java.lang.String,TiledObjectGroup> objectGroups
public TiledMapData(FileHandle fileHandle)
fileHandle - TiledExceptionpublic TiledMapData(TiledParser tiledParser, FileHandle fileHandle)
tiledParser - fileHandle - TiledExceptionpublic org.mini2Dx.gdx.utils.Array<AssetDescriptor> getDependencies()
public boolean loadTilesetTextures()
Tileset textures for this map if they are not already loadedpublic boolean loadTilesetTextures(AssetManager assetManager)
Tileset textures for this map if they are not already loaded
assetManager - The AssetManager to usepublic boolean loadTilesetTextures(TextureAtlas textureAtlas)
Tileset textures for this map if they are not already loaded
textureAtlas - The TextureAtlas to load textures frompublic boolean loadTilesetTextures(boolean loadObjectTemplateTilesets)
Tileset textures for this map if they are not already loaded
loadObjectTemplateTilesets - True if tilesets used by object templates should be loadedpublic boolean loadTilesetTextures(AssetManager assetManager, boolean loadObjectTemplateTilesets)
Tileset textures for this map if they are not already loaded
loadObjectTemplateTilesets - True if tilesets used by object templates should be loadedassetManager - The AssetManager to usepublic boolean loadTilesetTextures(TextureAtlas textureAtlas, boolean loadObjectTemplateTilesets)
Tileset textures for this map if they are not already loaded
loadObjectTemplateTilesets - True if tilesets used by object templates should be loadedtextureAtlas - The TextureAtlas to load textures frompublic void onBeginParsing(java.lang.String orientation,
java.lang.String staggerAxis,
java.lang.String staggerIndex,
Color backgroundColor,
int width,
int height,
int tileWidth,
int tileHeight,
int sideLength)
onBeginParsing in interface TiledParserListenerpublic boolean containsProperty(java.lang.String propertyName)
propertyName - The property name to search forpublic java.lang.String getProperty(java.lang.String propertyName)
propertyName - The property name to search forpublic void setProperty(java.lang.String propertyName,
java.lang.String value)
propertyName - The property name to set the value forvalue - The value of the property to setpublic void onMapPropertyParsed(java.lang.String propertyName,
java.lang.String value)
onMapPropertyParsed in interface TiledParserListenerpublic void onTilePropertiesParsed(Tile tile)
onTilePropertiesParsed in interface TiledParserListenerpublic void onTilesetParsed(Tileset parsedTileset)
onTilesetParsed in interface TiledParserListenerpublic void onTileLayerParsed(TileLayer parsedLayer)
onTileLayerParsed in interface TiledLayerParserListenerpublic void onObjectGroupParsed(TiledObjectGroup parsedObjectGroup)
onObjectGroupParsed in interface TiledLayerParserListenerpublic void onGroupLayerParsed(GroupLayer parsedLayer)
onGroupLayerParsed in interface TiledLayerParserListenerpublic void onObjectTemplateParsed(TiledObjectTemplate parsedObjectTemplate)
onObjectTemplateParsed in interface TiledParserListenerpublic TileLayer getTileLayer(java.lang.String name)
TileLayer with the given namename - The name to search forTileLayerpublic TileLayer getTileLayer(java.lang.String name, boolean recursive)
TileLayer with the given namename - The name to search forrecursive - False if only the root's immediate child layers should be searched (ignoring descendants)TileLayerpublic static TileLayer getTileLayer(org.mini2Dx.gdx.utils.Array<Layer> layers, java.lang.String name, boolean recursive)
TileLayer with the given namelayers - The layers to search throughname - The name to search forrecursive - False if only the immediate layers should be searched (ignoring descendants)TileLayerpublic TileLayer getTileLayer(int index)
TileLayer at the given indexindex - The index of the layerpublic TiledObjectGroup getObjectGroup(java.lang.String name)
TiledObjectGroup with the given namename - The name to search forTiledObjectGrouppublic TiledObjectGroup getObjectGroup(java.lang.String name, boolean recursive)
TiledObjectGroup with the given namename - The name to search forrecursive - False if only the immediate layers should be searched (ignoring descendants)TiledObjectGrouppublic static TiledObjectGroup getObjectGroup(org.mini2Dx.gdx.utils.Array<Layer> layers, org.mini2Dx.gdx.utils.ObjectMap<java.lang.String,TiledObjectGroup> objectGroups, java.lang.String name, boolean recursive)
TiledObjectGroup with the given namelayers - The layers to search throughobjectGroups - A map of layer names to object groupsname - The name to search forrecursive - False if only the immediate layers should be searched (ignoring descendants)TiledObjectGrouppublic GroupLayer getGroupLayer(java.lang.String name)
GroupLayer with the given namename - The name of the layerpublic GroupLayer getGroupLayer(java.lang.String name, boolean recursive)
GroupLayer with the given namename - The name of the layerrecursive - False if only the root's immediate child layers should be searched (ignoring descendants)public static GroupLayer getGroupLayer(org.mini2Dx.gdx.utils.Array<Layer> layers, java.lang.String name, boolean recursive)
GroupLayer with the given namelayers - The layers to search throughname - The name of the layerrecursive - False if only the immediate layers should be searched (ignoring descendants)public GroupLayer getGroupLayer(int index)
GroupLayer at the given indexindex - The index of the layerpublic java.lang.Iterable<TiledObjectGroup> getObjectGroups()
TiledObjectGroups in this mapTiledObjectGroupspublic int getLayerIndex(java.lang.String name)
TileLayer or TiledObjectGroup
with the given namename - The name to search forTileLayer or
TiledObjectGrouppublic int getLayerIndexIgnoreCase(java.lang.String name)
TileLayer or TiledObjectGroup
with the given name ignoring upper/lowercase differencesname - The name to search forTileLayer or
TiledObjectGrouppublic Tile getTile(int tileId)
Tile for the given tile IDtileId - The tile ID to search forTile with the given IDpublic Tile getTile(int x, int y, int layer)
Tile at the given coordinate on a specific layerx - The x coordinate (in tiles)y - The y coordinate (in tiles)layer - The layer indexTilepublic Orientation getOrientation()
Orientation of this mappublic StaggerAxis getStaggerAxis()
StaggerAxis of this mappublic StaggerIndex getStaggerIndex()
StaggerIndex of this mappublic int getSideLength()
public int getWidth()
public int getHeight()
public int getTileWidth()
public int getTileHeight()
public int getPixelWidth()
public int getPixelHeight()
public org.mini2Dx.gdx.utils.Array<Tileset> getTilesets()
Tilesets of this mappublic org.mini2Dx.gdx.utils.Array<Layer> getLayers()
Layers of this mappublic org.mini2Dx.gdx.utils.Array<Tile> getAnimatedTiles()
public int getTotalObjectGroups()
TiledObjectGroup instancespublic int getTotalLayers()
Layer instancespublic Color getBackgroundColor()
Color of the mappublic boolean containsAnimatedTiles()
public boolean isTilesetTexturesLoaded()
Tileset images have been loadedpublic boolean isTilesetTexturesLoaded(boolean ignoreObjectTemplateTilesets)
Tileset images have been loadedignoreObjectTemplateTilesets - True if tilesets referenced by object templates should be ignoredpublic FileHandle getFileHandle()
FileHandle for this datapublic void dispose()
public void dispose(boolean disposeTilesets)
disposeTilesets - True if tilesets should also be disposed