public class TsxTilesetSource extends TilesetSource
TilesetSource
loaded from a TSX file. Allows for sharing data
across multiple TiledMap
instances.Constructor and Description |
---|
TsxTilesetSource(com.badlogic.gdx.files.FileHandle tmxPath,
java.lang.String tsxPath) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsProperty(java.lang.String propertyName)
Returns if the tileset contains the specified property
|
void |
dispose() |
void |
drawTile(Graphics g,
int tileId,
int firstGid,
int renderX,
int renderY)
Draws a tile to the
Graphics context |
void |
drawTileset(Graphics g,
int renderX,
int renderY)
Draws the whole tileset to the
Graphics context |
com.badlogic.gdx.utils.Array<com.badlogic.gdx.assets.AssetDescriptor> |
getDependencies(com.badlogic.gdx.files.FileHandle tmxPath)
Returns the dependencies of this source
|
int |
getHeight()
Returns the height of this tileset in pixels
|
int |
getHeightInTiles()
Returns the height of this source in tiles
|
int |
getMargin()
Returns the margin at the borders of the tileset
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Returns the properties
Map of this Tileset |
java.lang.String |
getProperty(java.lang.String propertyName)
Returns the value of a specified property
|
int |
getSpacing()
Returns the internal spacing between each tile
|
Tile |
getTile(int tileId,
int firstGid)
Returns the
Tile for a given tile id |
Tile |
getTileByPosition(int x,
int y)
Returns the
Tile for a given x/y coordinate with the tileset
source |
int |
getTileHeight()
Returns the height of each tile in pixels
|
Sprite |
getTileImage(int tileId)
Returns the
Sprite for a given tile |
int |
getTileWidth()
Returns the width of each tile in pixels
|
java.lang.String |
getTsxPath() |
int |
getWidth()
Returns the width of this tileset in pixels
|
int |
getWidthInTiles()
Returns the width of this source in tiles
|
boolean |
isTextureLoaded()
Returns if the tileset texture image is loaded
|
void |
loadTexture(com.badlogic.gdx.assets.AssetManager assetManager,
com.badlogic.gdx.files.FileHandle tmxPath)
Loads the tileset's texture image
|
void |
loadTexture(com.badlogic.gdx.files.FileHandle tmxPath)
Loads the tileset's texture image
|
void |
setProperty(java.lang.String propertyName,
java.lang.String value)
Sets the value of a specified property
|
contains, getTileId, getTileImage, getTileX, getTileY
public TsxTilesetSource(com.badlogic.gdx.files.FileHandle tmxPath, java.lang.String tsxPath)
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.assets.AssetDescriptor> getDependencies(com.badlogic.gdx.files.FileHandle tmxPath)
TilesetSource
getDependencies
in class TilesetSource
tmxPath
- The path of the TMX filepublic void loadTexture(com.badlogic.gdx.files.FileHandle tmxPath)
TilesetSource
loadTexture
in class TilesetSource
tmxPath
- The path of the TMX filepublic void loadTexture(com.badlogic.gdx.assets.AssetManager assetManager, com.badlogic.gdx.files.FileHandle tmxPath)
TilesetSource
loadTexture
in class TilesetSource
assetManager
- The AssetManager
to usetmxPath
- The path of the TMX filepublic boolean isTextureLoaded()
TilesetSource
isTextureLoaded
in class TilesetSource
public Sprite getTileImage(int tileId)
TilesetSource
Sprite
for a given tilegetTileImage
in class TilesetSource
tileId
- The tile id to retrieveSprite
or null if that textures haven't been loadedpublic int getWidthInTiles()
TilesetSource
getWidthInTiles
in class TilesetSource
public int getHeightInTiles()
TilesetSource
getHeightInTiles
in class TilesetSource
public void drawTile(Graphics g, int tileId, int firstGid, int renderX, int renderY)
TilesetSource
Graphics
contextdrawTile
in class TilesetSource
g
- The Graphics
context available for renderingtileId
- The tile id to renderfirstGid
- The first gid of the parent tilesetrenderX
- The X coordinate to render atrenderY
- The Y coordinate to render atpublic void drawTileset(Graphics g, int renderX, int renderY)
TilesetSource
Graphics
contextdrawTileset
in class TilesetSource
g
- The Graphics
context available for renderingrenderX
- The X coordinate to render atrenderY
- The Y coordinate to render atpublic int getWidth()
TilesetSource
getWidth
in class TilesetSource
public int getHeight()
TilesetSource
getHeight
in class TilesetSource
public int getTileWidth()
TilesetSource
getTileWidth
in class TilesetSource
public int getTileHeight()
TilesetSource
getTileHeight
in class TilesetSource
public int getSpacing()
TilesetSource
getSpacing
in class TilesetSource
public int getMargin()
TilesetSource
getMargin
in class TilesetSource
public Tile getTileByPosition(int x, int y)
TilesetSource
Tile
for a given x/y coordinate with the tileset
sourcegetTileByPosition
in class TilesetSource
x
- The x coordinate of the tile within the tileset (in tiles)y
- The y coordinate of the tile within the tileset (in tiles)Tile
public Tile getTile(int tileId, int firstGid)
TilesetSource
Tile
for a given tile idgetTile
in class TilesetSource
tileId
- The tile id to look upfirstGid
- The first gid for the tilesetTile
public boolean containsProperty(java.lang.String propertyName)
TilesetSource
containsProperty
in class TilesetSource
propertyName
- The property name to search forpublic java.lang.String getProperty(java.lang.String propertyName)
TilesetSource
getProperty
in class TilesetSource
propertyName
- The property name to search forpublic void setProperty(java.lang.String propertyName, java.lang.String value)
TilesetSource
setProperty
in class TilesetSource
propertyName
- The property name to set the value forvalue
- The value of the property to setpublic java.util.Map<java.lang.String,java.lang.String> getProperties()
TilesetSource
Map
of this Tileset
getProperties
in class TilesetSource
public java.lang.String getTsxPath()
public void dispose()