public class TsxTilesetSource extends TilesetSource
TilesetSource loaded from a TSX file. Allows for sharing data
across multiple TiledMap instances.| Modifier and Type | Field and Description |
|---|---|
static int |
TILESET_TYPE |
| Constructor and Description |
|---|
TsxTilesetSource(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,
float alpha)
Draws a tile to the
Graphics context |
void |
drawTileset(Graphics g,
int renderX,
int renderY,
float alpha)
Draws the whole tileset to the
Graphics context |
boolean |
equals(java.lang.Object o) |
static TsxTilesetSource |
fromInputStream(TiledMapData tiledMapData,
java.io.DataInputStream inputStream) |
org.mini2Dx.gdx.utils.Array<Tile> |
getAnimatedTiles()
Returns all animated tiles in this tileset source
|
org.mini2Dx.gdx.utils.Array<AssetDescriptor> |
getDependencies(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
|
java.lang.String |
getInternalUuid()
Returns a UUID generated by mini2Dx
|
int |
getMargin()
Returns the margin at the borders of the tileset
|
org.mini2Dx.gdx.utils.ObjectMap<java.lang.String,java.lang.String> |
getProperties()
Returns the properties
ObjectMap 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 |
ImageTilesetSource |
getTileset() |
int |
getTilesetSourceType()
Returns a int representation of the source type.
|
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
|
int |
hashCode() |
boolean |
isTextureLoaded()
Returns if the tileset texture image is loaded
|
void |
loadTexture(AssetManager assetManager,
FileHandle tmxPath)
Loads the tileset's texture image
|
void |
loadTexture(FileHandle tmxPath)
Loads the tileset's texture image
|
void |
loadTexture(TextureAtlas textureAtlas)
Loads the texture from a
TextureAtlas |
void |
readData(java.io.DataInputStream inputStream)
Deserializes this object from a
DataInputStream |
void |
registerAnimatedTile(Tile tile)
Registers an animated tile in this tileset source
|
void |
setProperty(java.lang.String propertyName,
java.lang.String value)
Sets the value of a specified property
|
void |
setTsxPath(java.lang.String tsxPath) |
static void |
updateAllAnimatedTiles(float delta)
Updates animated tiles across all tilesets even if they are unreferenced by a TiledMap
|
void |
updateAnimatedTiles(float delta)
Updates all animated tiles
|
void |
writeData(java.io.DataOutputStream outputStream)
Serializes this object to a
DataOutputStream |
contains, getTileId, getTileImage, getTileX, getTileYpublic static final int TILESET_TYPE
public TsxTilesetSource(FileHandle tmxPath, java.lang.String tsxPath)
public static void updateAllAnimatedTiles(float delta)
delta - The time since the last frame (in seconds)public static TsxTilesetSource fromInputStream(TiledMapData tiledMapData, java.io.DataInputStream inputStream) throws java.io.IOException
java.io.IOExceptionpublic void writeData(java.io.DataOutputStream outputStream)
throws java.io.IOException
GameDataSerializableDataOutputStreamoutputStream - The DataOutputStream to write tojava.io.IOException - Thrown if an error occurs during I/Opublic void readData(java.io.DataInputStream inputStream)
throws java.io.IOException
GameDataSerializableDataInputStreaminputStream - The DataInputStream to read fromjava.io.IOException - Thrown if an error occurs during I/Opublic org.mini2Dx.gdx.utils.Array<AssetDescriptor> getDependencies(FileHandle tmxPath)
TilesetSourcegetDependencies in class TilesetSourcetmxPath - The path of the TMX filepublic void loadTexture(FileHandle tmxPath)
TilesetSourceloadTexture in class TilesetSourcetmxPath - The path of the TMX filepublic void loadTexture(AssetManager assetManager, FileHandle tmxPath)
TilesetSourceloadTexture in class TilesetSourceassetManager - The AssetManager to usetmxPath - The path of the TMX filepublic void loadTexture(TextureAtlas textureAtlas)
TilesetSourceTextureAtlasloadTexture in class TilesetSourcetextureAtlas - The TextureAtlas to usepublic boolean isTextureLoaded()
TilesetSourceisTextureLoaded in class TilesetSourcepublic Sprite getTileImage(int tileId)
TilesetSourceSprite for a given tilegetTileImage in class TilesetSourcetileId - The tile id to retrieveSprite or null if that textures haven't been loadedpublic int getWidthInTiles()
TilesetSourcegetWidthInTiles in class TilesetSourcepublic int getHeightInTiles()
TilesetSourcegetHeightInTiles in class TilesetSourcepublic void drawTile(Graphics g, int tileId, int firstGid, int renderX, int renderY, float alpha)
TilesetSourceGraphics contextdrawTile in class TilesetSourceg - 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 atalpha - The alpha blend value (1.0 by default)public void drawTileset(Graphics g, int renderX, int renderY, float alpha)
TilesetSourceGraphics contextdrawTileset in class TilesetSourceg - The Graphics context available for renderingrenderX - The X coordinate to render atrenderY - The Y coordinate to render atalpha - The alpha blend value (1.0 by default)public int getWidth()
TilesetSourcegetWidth in class TilesetSourcepublic int getHeight()
TilesetSourcegetHeight in class TilesetSourcepublic int getTileWidth()
TilesetSourcegetTileWidth in class TilesetSourcepublic int getTileHeight()
TilesetSourcegetTileHeight in class TilesetSourcepublic int getSpacing()
TilesetSourcegetSpacing in class TilesetSourcepublic int getMargin()
TilesetSourcegetMargin in class TilesetSourcepublic Tile getTileByPosition(int x, int y)
TilesetSourceTile for a given x/y coordinate with the tileset
sourcegetTileByPosition in class TilesetSourcex - The x coordinate of the tile within the tileset (in tiles)y - The y coordinate of the tile within the tileset (in tiles)Tilepublic Tile getTile(int tileId, int firstGid)
TilesetSourceTile for a given tile idgetTile in class TilesetSourcetileId - The tile id to look upfirstGid - The first gid for the tilesetTilepublic boolean containsProperty(java.lang.String propertyName)
TilesetSourcecontainsProperty in class TilesetSourcepropertyName - The property name to search forpublic java.lang.String getProperty(java.lang.String propertyName)
TilesetSourcegetProperty in class TilesetSourcepropertyName - The property name to search forpublic void setProperty(java.lang.String propertyName,
java.lang.String value)
TilesetSourcesetProperty in class TilesetSourcepropertyName - The property name to set the value forvalue - The value of the property to setpublic org.mini2Dx.gdx.utils.ObjectMap<java.lang.String,java.lang.String> getProperties()
TilesetSourceObjectMap of this TilesetgetProperties in class TilesetSourcepublic void updateAnimatedTiles(float delta)
TilesetSourceupdateAnimatedTiles in class TilesetSourcedelta - The time since the last frame (in seconds)public org.mini2Dx.gdx.utils.Array<Tile> getAnimatedTiles()
TilesetSourcegetAnimatedTiles in class TilesetSourcepublic void registerAnimatedTile(Tile tile)
TilesetSourceregisterAnimatedTile in class TilesetSourcetile - The animated Tilepublic java.lang.String getInternalUuid()
TilesetSourcegetInternalUuid in class TilesetSourcepublic int getTilesetSourceType()
TilesetSourcegetTilesetSourceType in class TilesetSourceImageTilesetSource.TILESET_TYPE or TILESET_TYPEpublic ImageTilesetSource getTileset()
public java.lang.String getTsxPath()
public void setTsxPath(java.lang.String tsxPath)
public void dispose()
public boolean equals(java.lang.Object o)
equals in class TilesetSourcepublic int hashCode()
hashCode in class java.lang.Object