public class TiledMap
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
| static boolean | FAST_RENDER_EMPTY_LAYERSSet to true to optimise CPU time (at cost of memory usage) for rendering tile layers that are mostly empty | 
| static boolean | STRICT_LAYER_VISIBILITYSet to true to tell the renderer to not render layers marked as hidden in Tiled | 
| Constructor and Description | 
|---|
| TiledMap(com.badlogic.gdx.files.FileHandle fileHandle)Constructs a map from a TMX file | 
| TiledMap(com.badlogic.gdx.files.FileHandle fileHandle,
        boolean loadTilesetTextures,
        boolean cacheLayers)Constructs a map from a TMX file | 
| TiledMap(TiledMapData tiledMapData,
        boolean loadTilesetTextures,
        boolean cacheLayers) | 
| TiledMap(TiledParser parser,
        com.badlogic.gdx.files.FileHandle fileHandle,
        boolean loadTilesetTextures,
        boolean cacheLayers)Constructs a map from a TMX file | 
| 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 | 
| 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  Colorof the map | 
| GroupLayer | getGroupLayer(int index)Returns the  GroupLayerat the given index | 
| GroupLayer | getGroupLayer(java.lang.String name)Returns the  GroupLayerwith the given name | 
| int | getHeight()Returns the height of the map in tiles | 
| int | getLayerIndex(java.lang.String name)Returns the index of the  TileLayerorTiledObjectGroupwith the given name | 
| int | getLayerIndexIgnoreCase(java.lang.String name)Returns the index of the  TileLayerorTiledObjectGroupwith the given name ignoring upper/lowercase differences | 
| com.badlogic.gdx.utils.Array<Layer> | getLayers()Returns the  Layers of this map | 
| TiledObjectGroup | getObjectGroup(java.lang.String name)Returns the  TiledObjectGroupwith the given name | 
| java.lang.Iterable<TiledObjectGroup> | getObjectGroups()Returns all the  TiledObjectGroups in this map | 
| Orientation | getOrientation()Returns the  Orientationof 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  StaggerAxisof this map | 
| StaggerIndex | getStaggerIndex()Returns the  StaggerIndexof this map | 
| Tile | getTile(int tileId)Returns the  Tilefor the given tile ID | 
| Tile | getTile(int x,
       int y,
       int layer)Returns the  Tileat the given coordinate on a specific layer | 
| int | getTileHeight()Returns the height of tiles in pixels | 
| TileLayer | getTileLayer(int index)Returns the  TileLayerat the given index | 
| TileLayer | getTileLayer(java.lang.String name)Returns the  TileLayerwith the given name | 
| com.badlogic.gdx.utils.Array<Tileset> | getTilesets()Returns the  Tilesets of this map | 
| int | getTileWidth()Returns the width of tiles in pixels | 
| int | getTotalObjectGroups()Returns the total amount of  TiledObjectGroupinstances | 
| int | getWidth()Returns the width of the map in tiles | 
| boolean | isTilesetTexturesLoaded()Returns if the  Tilesetimages have been loaded | 
| boolean | isTilesetTexturesLoaded(boolean ignoreObjectTemplateTilesets)Returns if the  Tilesetimages have been loaded | 
| void | loadTilesetTextures()Loads all  Tilesettextures for this map if they are not already loaded | 
| void | loadTilesetTextures(com.badlogic.gdx.assets.AssetManager assetManager)Loads all  Tilesettextures for this map if they are not already loaded | 
| void | loadTilesetTextures(com.badlogic.gdx.assets.AssetManager assetManager,
                   boolean loadObjectTemplateTilesets)Loads all  Tilesettextures for this map if they are not already loaded | 
| void | loadTilesetTextures(boolean loadObjectTemplateTilesets)Loads all  Tilesettextures for this map if they are not already loaded | 
| void | loadTilesetTextures(com.badlogic.gdx.graphics.g2d.TextureAtlas textureAtlas)Loads all  Tilesettextures for this map if they are not already loaded | 
| void | loadTilesetTextures(com.badlogic.gdx.graphics.g2d.TextureAtlas textureAtlas,
                   boolean loadObjectTemplateTilesets)Loads all  Tilesettextures for this map if they are not already loaded | 
| protected void | onLayerRendered(Graphics g,
               TileLayer layer,
               int startTileX,
               int startTileY,
               int widthInTiles,
               int heightInTiles)Developers can override this method to implement sprite rendering | 
| 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 | setTiledObjectGroupRenderer(TiledObjectGroupRenderer tiledObjectGroupRenderer)Sets the  TiledObjectGroupRendererimplementation to use for
 rendering | 
| void | setTileLayerRenderer(TileLayerRenderer tileLayerRenderer)Sets the  TileLayerRendererimplementation to use for rendering | 
| void | update(float delta)Updates map elements such as animated tiles | 
public static boolean STRICT_LAYER_VISIBILITY
public static boolean FAST_RENDER_EMPTY_LAYERS
public TiledMap(com.badlogic.gdx.files.FileHandle fileHandle)
fileHandle - A FileHandle to a .tmx fileTiledException - Thrown if there were issues with the loaded mappublic TiledMap(com.badlogic.gdx.files.FileHandle fileHandle,
                boolean loadTilesetTextures,
                boolean cacheLayers)
fileHandle - A FileHandle to a .tmx fileloadTilesetTextures - True if the tileset images should be loadedcacheLayers - True if the tile layers should be cached during renderingTiledException - Thrown if there were issues with the loaded mappublic TiledMap(TiledParser parser, com.badlogic.gdx.files.FileHandle fileHandle, boolean loadTilesetTextures, boolean cacheLayers)
parser - An existing TiledParser instancefileHandle - A FileHandle to a .tmx fileloadTilesetTextures - True if the tileset images should be loadedTiledException - Thrown if there were issues with the loaded mappublic TiledMap(TiledMapData tiledMapData, boolean loadTilesetTextures, boolean cacheLayers)
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 void loadTilesetTextures()
Tileset textures for this map if they are not already loadedpublic void loadTilesetTextures(com.badlogic.gdx.assets.AssetManager assetManager)
Tileset textures for this map if they are not already loadedassetManager - The AssetManager to usepublic void loadTilesetTextures(com.badlogic.gdx.graphics.g2d.TextureAtlas textureAtlas)
Tileset textures for this map if they are not already loadedtextureAtlas - The TextureAtlas to load textures frompublic void loadTilesetTextures(boolean loadObjectTemplateTilesets)
Tileset textures for this map if they are not already loadedloadObjectTemplateTilesets - True if tilesets used by object templates should be loadedpublic void loadTilesetTextures(com.badlogic.gdx.assets.AssetManager assetManager,
                                boolean loadObjectTemplateTilesets)
Tileset textures for this map if they are not already loadedloadObjectTemplateTilesets - True if tilesets used by object templates should be loadedassetManager - The AssetManager to usepublic void loadTilesetTextures(com.badlogic.gdx.graphics.g2d.TextureAtlas textureAtlas,
                                boolean loadObjectTemplateTilesets)
Tileset textures for this map if they are not already loadedloadObjectTemplateTilesets - True if tilesets used by object templates should be loadedtextureAtlas - The TextureAtlas to load textures frompublic void update(float delta)
delta - The time since the last frame (in seconds)public 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 TileLayer getTileLayer(java.lang.String name)
TileLayer with the given namename - The name to search forTileLayerpublic TileLayer getTileLayer(int index)
TileLayer at the given indexindex - The index of the layerpublic GroupLayer getGroupLayer(java.lang.String name)
GroupLayer with the given namename - The name of the layerpublic GroupLayer getGroupLayer(int index)
GroupLayer 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 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 void dispose()
public void dispose(boolean disposeTilesets)
disposeTilesets - True if tilesets should also be disposedpublic 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 com.badlogic.gdx.utils.Array<Tileset> getTilesets()
Tilesets of this mappublic com.badlogic.gdx.utils.Array<Layer> getLayers()
Layers of this mappublic int getTotalObjectGroups()
TiledObjectGroup instancespublic com.badlogic.gdx.graphics.Color getBackgroundColor()
Color of the mappublic void setTileLayerRenderer(TileLayerRenderer tileLayerRenderer)
TileLayerRenderer implementation to use for renderingtileLayerRenderer - The TileLayerRenderer to usepublic void setTiledObjectGroupRenderer(TiledObjectGroupRenderer tiledObjectGroupRenderer)
TiledObjectGroupRenderer implementation to use for
 renderingtiledObjectGroupRenderer - The TiledObjectGroupRenderer to usepublic boolean containsAnimatedTiles()