Class Tileset
Represents a tileset containing tiles from a texture atlas. Manages texture coordinates and tile properties.
public class Tileset
- Inheritance
-
Tileset
- Inherited Members
Constructors
Tileset(string, int, int, int, int, int)
Creates a new tileset with the specified properties.
public Tileset(string name, int firstGid, int tileWidth, int tileHeight, int tileCount, int columns)
Parameters
namestringTileset name
firstGidintFirst global ID
tileWidthintWidth of each tile
tileHeightintHeight of each tile
tileCountintTotal number of tiles
columnsintNumber of columns in the texture
Properties
Columns
public int Columns { get; set; }
Property Value
FirstGid
public int FirstGid { get; set; }
Property Value
ImagePath
public string ImagePath { get; set; }
Property Value
IsTextureLoaded
public bool IsTextureLoaded { get; set; }
Property Value
Name
public string Name { get; set; }
Property Value
Properties
public Dictionary<string, string> Properties { get; set; }
Property Value
Texture
public Texture2D Texture { get; set; }
Property Value
- Texture2D
TileCount
public int TileCount { get; set; }
Property Value
TileHeight
public int TileHeight { get; set; }
Property Value
TileProperties
public Dictionary<int, TileProperties> TileProperties { get; set; }
Property Value
TileWidth
public int TileWidth { get; set; }
Property Value
Methods
ContainsTile(int)
Checks if a global tile ID belongs to this tileset.
public bool ContainsTile(int globalTileId)
Parameters
globalTileIdintGlobal tile ID
Returns
- bool
True if the tile belongs to this tileset
GetTileProperties(int)
Gets the tile properties for a specific local tile ID.
public TileProperties? GetTileProperties(int localTileId)
Parameters
localTileIdintLocal tile ID within this tileset
Returns
- TileProperties
Tile properties, or null if none defined
GetTileSourceRect(int)
Gets the source rectangle for a specific tile in the tileset texture.
public Rectangle GetTileSourceRect(int localTileId)
Parameters
localTileIdintLocal tile ID within this tileset (0-based)
Returns
- Rectangle
Rectangle defining the tile's position in the texture
GlobalToLocal(int)
Converts a global tile ID to a local tile ID for this tileset.
public int GlobalToLocal(int globalTileId)
Parameters
globalTileIdintGlobal tile ID
Returns
- int
Local tile ID, or -1 if the tile doesn't belong to this tileset
LoadTexture(string)
Loads the tileset texture from the specified path.
public void LoadTexture(string imagePath)
Parameters
imagePathstringPath to the texture file
LocalToGlobal(int)
Converts a local tile ID to a global tile ID.
public int LocalToGlobal(int localTileId)
Parameters
localTileIdintLocal tile ID
Returns
- int
Global tile ID
SetTileProperties(int, TileProperties)
Sets properties for a specific tile.
public void SetTileProperties(int localTileId, TileProperties properties)
Parameters
localTileIdintLocal tile ID within this tileset
propertiesTilePropertiesProperties to set
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
UnloadTexture()
Unloads the tileset texture from memory.
public void UnloadTexture()