public class TiledMap extends Object implements TiledParserListener
| Modifier and Type | Field and Description |
|---|---|
protected List<TiledObjectGroup> |
objectGroups |
protected List<TileLayer> |
tileLayers |
protected 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 loadMaps)
Constructs a map from a TMX file
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsProperty(String propertyName)
Returns if the map contains the specified property
|
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 width,
int height)
Draws a section of the map at the specified coordinates
|
void |
draw(Graphics g,
int x,
int y,
int startTileX,
int startTileY,
int width,
int height,
int layer)
Draws a section of a specified layer of the map at the specified coordinates
|
int |
getHeight()
Returns the height of the map in tiles
|
int |
getLayerIndex(String name)
Returns the index of the
TileLayer with the given name |
TiledObjectGroup |
getObjectGroup(String name)
Returns the
TiledObjectGroup with the given name |
List<TiledObjectGroup> |
getObjectGroups()
Returns the
TiledObjectGroups of this map |
Orientation |
getOrientation()
Returns the
Orientation of this map |
String |
getProperty(String propertyName)
Returns the value of a specified property
|
int |
getTileHeight()
Returns the height of tiles in pixels
|
TileLayer |
getTileLayer(String name)
Returns the
TileLayer with the given name |
List<TileLayer> |
getTileLayers()
Returns the
TileLayers of this map |
List<Tileset> |
getTilesets()
Returns the
Tilesets of this map |
int |
getTileWidth()
Returns the width of tiles in pixels
|
int |
getWidth()
Returns the width of the map in tiles
|
void |
onBeginParsing(String orientation,
int width,
int height,
int tileWidth,
int tileHeight) |
protected void |
onLayerRendered(TileLayer layer,
int startTileX,
int startTileY,
int width,
int height)
Developers can override this method to implement sprite rendering
|
void |
onMapPropertyParsed(String propertyName,
String value) |
void |
onObjectGroupParsed(TiledObjectGroup parsedObjectGroup) |
void |
onTileLayerParsed(TileLayer parsedLayer) |
void |
onTilePropertyParsed(int tileId,
String propertyName,
String value) |
void |
onTilesetParsed(Tileset parsedTileset) |
void |
setProperty(String propertyName,
String value)
Sets the value of a specified property
|
protected List<TiledObjectGroup> objectGroups
public TiledMap()
public TiledMap(com.badlogic.gdx.files.FileHandle fileHandle)
throws IOException
fileHandle - A FileHandle to a .tmx fileIOException - Thrown if the map file could not be parsedpublic TiledMap(com.badlogic.gdx.files.FileHandle fileHandle,
boolean loadMaps)
throws IOException
fileHandle - A FileHandle to a .tmx fileloadMaps - True if the tileset images should be loadedIOException - Thrown if the map file could not be parsedpublic 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 width, int height)
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 fromwidth - The amount of tiles across the x axis to renderheight - The amount of tiles across the y axis to renderpublic void draw(Graphics g, int x, int y, int startTileX, int startTileY, int width, int height, 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 fromwidth - The amount of tiles across the x axis to renderheight - The amount of tiles across the y axis to renderlayer - The layer index to renderprotected void onLayerRendered(TileLayer layer, int startTileX, int startTileY, int width, int height)
layer - The TileLayer which was just renderedstartTileX - The x coordinate in tiles where rendering startedstartTileY - The y coordinate in tiles where rendering startedwidth - The amount of tiles that were rendered along the X axisheight - The amount of tiles that were rendered along the Y axispublic boolean containsProperty(String propertyName)
propertyName - The property name to search forpublic String getProperty(String propertyName)
propertyName - The property name to search forpublic void setProperty(String propertyName, String value)
propertyName - The property name to set the value forvalue - The value of the property to setpublic void onBeginParsing(String orientation, int width, int height, int tileWidth, int tileHeight)
onBeginParsing in interface TiledParserListenerpublic void onMapPropertyParsed(String propertyName, String value)
onMapPropertyParsed in interface TiledParserListenerpublic void onTilePropertyParsed(int tileId,
String propertyName,
String value)
onTilePropertyParsed 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(String name)
TileLayer with the given namename - The name to search forTileLayerpublic TiledObjectGroup getObjectGroup(String name)
TiledObjectGroup with the given namename - The name to search forTiledObjectGrouppublic int getLayerIndex(String name)
TileLayer with the given namename - The name to search forTileLayerpublic Orientation getOrientation()
Orientation of this mappublic int getWidth()
public int getHeight()
public int getTileWidth()
public int getTileHeight()
public List<Tileset> getTilesets()
Tilesets of this mappublic List<TileLayer> getTileLayers()
TileLayers of this mappublic List<TiledObjectGroup> getObjectGroups()
TiledObjectGroups of this mapCopyright © 2014. All rights reserved.