public class TiledMap extends java.lang.Object implements TiledParserListener
TileLayers
to improve render speeds| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<TiledObjectGroup> |
objectGroups |
protected java.util.List<TileLayer> |
tileLayers |
protected java.util.List<Tileset> |
tilesets |
| Constructor and Description |
|---|
TiledMap()
Constructs an empty map
|
TiledMap(com.badlogic.gdx.files.FileHandle fileHandle)
Constructs a map from a TMX file
|
TiledMap(com.badlogic.gdx.files.FileHandle fileHandle,
boolean loadTilesets,
boolean cacheLayers)
Constructs a map from a TMX file
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsProperty(java.lang.String propertyName)
Returns if the map contains the specified property
|
void |
dispose()
Releases any resources used by this TiledMap
|
void |
draw(Graphics g,
int x,
int y)
Draws the entire map at the specified coordinates
|
void |
draw(Graphics g,
int x,
int y,
int layer)
Draws a layer of the map at the specified coordinates
|
void |
draw(Graphics g,
int x,
int y,
int startTileX,
int startTileY,
int widthInTiles,
int heightInTiles)
Draws a section of the map at the specified coordinates
|
void |
draw(Graphics g,
int x,
int y,
int startTileX,
int startTileY,
int widthInTiles,
int heightInTiles,
int layer)
Draws a section of a specified layer of the map at the specified
coordinates
|
com.badlogic.gdx.graphics.Color |
getBackgroundColor()
Returns the background
Color of the map |
int |
getHeight()
Returns the height of the map in tiles
|
int |
getLayerIndex(java.lang.String name)
Returns the index of the
TileLayer with the given name |
TiledObjectGroup |
getObjectGroup(java.lang.String name)
Returns the
TiledObjectGroup with the given name |
java.util.List<TiledObjectGroup> |
getObjectGroups()
Returns the
TiledObjectGroups of this map |
Orientation |
getOrientation()
Returns the
Orientation of this map |
java.lang.String |
getProperty(java.lang.String propertyName)
Returns the value of a specified property
|
Tile |
getTile(int tileId)
Returns the
Tile for the given tile ID |
int |
getTileHeight()
Returns the height of tiles in pixels
|
TileLayer |
getTileLayer(java.lang.String name)
Returns the
TileLayer with the given name |
java.util.List<TileLayer> |
getTileLayers()
Returns the
TileLayers of this map |
java.util.List<Tileset> |
getTilesets()
Returns the
Tilesets of this map |
int |
getTileWidth()
Returns the width of tiles in pixels
|
int |
getTotalTilesetsLoaded()
Returns the total amount of
Tilesets loaded |
int |
getWidth()
Returns the width of the map in tiles
|
boolean |
isTilesetsLoaded()
Returns if the
Tileset images have been loaded |
void |
loadTileset(int tilesetIndex)
Loads a specific
Tileset |
void |
loadTilesets()
Loads all
Tilesets for this map if they are not already loaded |
void |
onBeginParsing(java.lang.String orientation,
com.badlogic.gdx.graphics.Color backgroundColor,
int width,
int height,
int tileWidth,
int tileHeight) |
protected void |
onLayerRendered(Graphics g,
TileLayer layer,
int startTileX,
int startTileY,
int widthInTiles,
int heightInTiles)
Developers can override this method to implement sprite rendering
|
void |
onMapPropertyParsed(java.lang.String propertyName,
java.lang.String value) |
void |
onObjectGroupParsed(TiledObjectGroup parsedObjectGroup) |
void |
onTileLayerParsed(TileLayer parsedLayer) |
void |
onTilePropertiesParsed(Tile tile) |
void |
onTilesetParsed(Tileset parsedTileset) |
protected boolean |
preLayerRendered(Graphics g,
TileLayer layer,
int startTileX,
int startTileY,
int widthInTiles,
int heightInTiles)
Developers can override this method which is called before a layer is
rendered
To prevent the layer from rendering, return false from this method.
|
void |
setProperty(java.lang.String propertyName,
java.lang.String value)
Sets the value of a specified property
|
void |
setTileLayerRenderer(TileLayerRenderer tileLayerRenderer)
Sets the
TileLayerRenderer implementation to use for rendering |
protected java.util.List<Tileset> tilesets
protected java.util.List<TileLayer> tileLayers
protected java.util.List<TiledObjectGroup> objectGroups
public TiledMap()
public TiledMap(com.badlogic.gdx.files.FileHandle fileHandle)
throws TiledException
fileHandle - A FileHandle to a .tmx fileTiledException - Thrown if there were issues with the loaded mappublic TiledMap(com.badlogic.gdx.files.FileHandle fileHandle,
boolean loadTilesets,
boolean cacheLayers)
throws TiledException
fileHandle - A FileHandle to a .tmx fileloadTilesets - True if the tileset images should be loaded and the map
pre-renderedTiledException - Thrown if there were issues with the loaded mappublic boolean isTilesetsLoaded()
Tileset images have been loadedpublic int getTotalTilesetsLoaded()
Tilesets loadedpublic void loadTileset(int tilesetIndex)
TilesettilesetIndex - public void loadTilesets()
Tilesets for this map if they are not already loadedpublic void draw(Graphics g, int x, int y)
g - The Graphics context available for renderingx - The x coordinate to render aty - The y coordinate to render atpublic void draw(Graphics g, int x, int y, int layer)
g - The Graphics context available for renderingx - The x coordinate to render aty - The y coordinate to render atlayer - The layer index to renderpublic void draw(Graphics g, int x, int y, int startTileX, int startTileY, int widthInTiles, int heightInTiles)
g - The Graphics context available for renderingx - The x coordinate to render aty - The y coordinate to render atstartTileX - The x tile coordinate in the map to start fromstartTileY - The y tile coordinate in the map to start fromwidthInTiles - The amount of tiles across the x axis to renderheightInTiles - The amount of tiles across the y axis to renderpublic void draw(Graphics g, int x, int y, int startTileX, int startTileY, int widthInTiles, int heightInTiles, int layer)
g - The Graphics context available for renderingx - The x coordinate to render aty - The y coordinate to render atstartTileX - The x tile coordinate in the map to start fromstartTileY - The y tile coordinate in the map to start fromwidthInTiles - The amount of tiles across the x axis to renderheightInTiles - The amount of tiles across the y axis to renderlayer - The layer index to renderprotected boolean preLayerRendered(Graphics g, TileLayer layer, int startTileX, int startTileY, int widthInTiles, int heightInTiles)
g - The Graphics context used for renderinglayer - The TileLayer which was just renderedstartTileX - The x coordinate in tiles where rendering startedstartTileY - The y coordinate in tiles where rendering startedwidthInTiles - The amount of tiles that were rendered along the X axisheightInTiles - The amount of tiles that were rendered along the Y axisprotected void onLayerRendered(Graphics g, TileLayer layer, int startTileX, int startTileY, int widthInTiles, int heightInTiles)
g - The Graphics context used for renderinglayer - The TileLayer which was just renderedstartTileX - The x coordinate in tiles where rendering startedstartTileY - The y coordinate in tiles where rendering startedwidthInTiles - The amount of tiles that were rendered along the X axisheightInTiles - The amount of tiles that were rendered along the Y axispublic 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 onBeginParsing(java.lang.String orientation,
com.badlogic.gdx.graphics.Color backgroundColor,
int width,
int height,
int tileWidth,
int tileHeight)
onBeginParsing in interface TiledParserListenerpublic 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 TiledParserListenerpublic void onObjectGroupParsed(TiledObjectGroup parsedObjectGroup)
onObjectGroupParsed in interface TiledParserListenerpublic TileLayer getTileLayer(java.lang.String name)
TileLayer with the given namename - The name to search forTileLayerpublic TiledObjectGroup getObjectGroup(java.lang.String name)
TiledObjectGroup with the given namename - The name to search forTiledObjectGrouppublic int getLayerIndex(java.lang.String name)
TileLayer with the given namename - The name to search forTileLayerpublic Tile getTile(int tileId)
Tile for the given tile IDtileId - The tile ID to search forTile with the given IDpublic void dispose()
public Orientation getOrientation()
Orientation of this mappublic int getWidth()
public int getHeight()
public int getTileWidth()
public int getTileHeight()
public java.util.List<Tileset> getTilesets()
Tilesets of this mappublic java.util.List<TileLayer> getTileLayers()
TileLayers of this mappublic java.util.List<TiledObjectGroup> getObjectGroups()
TiledObjectGroups of this mappublic com.badlogic.gdx.graphics.Color getBackgroundColor()
Color of the mappublic void setTileLayerRenderer(TileLayerRenderer tileLayerRenderer)
TileLayerRenderer implementation to use for renderingtileLayerRenderer - The TileLayerRenderer to use