Class TilemapLayer
Represents a single layer within a tilemap. Contains tile data and layer-specific properties.
public class TilemapLayer
- Inheritance
-
TilemapLayer
- Inherited Members
Constructors
TilemapLayer(string, int, int)
Creates a new tilemap layer with specified dimensions.
public TilemapLayer(string name, int width, int height)
Parameters
Properties
Height
public int Height { get; set; }
Property Value
Name
public string Name { get; set; }
Property Value
Opacity
public float Opacity { get; set; }
Property Value
Properties
public Dictionary<string, string> Properties { get; set; }
Property Value
Visible
public bool Visible { get; set; }
Property Value
Width
public int Width { get; set; }
Property Value
Methods
Clear()
Clears all tiles in the layer (sets all to 0).
public void Clear()
GetTileCount()
Gets the number of non-empty tiles in the layer.
public int GetTileCount()
Returns
- int
Count of tiles
GetTileId(int, int)
Gets the tile ID at the specified coordinates.
public int GetTileId(int x, int y)
Parameters
Returns
- int
Tile ID, or 0 if empty or out of bounds
HasTiles()
Checks if the layer contains any non-empty tiles.
public bool HasTiles()
Returns
- bool
True if the layer has any tiles
LoadFromArray(int[])
Loads tile data from a flat array (as typically found in TMX files).
public void LoadFromArray(int[] data)
Parameters
dataint[]Flat array of tile IDs
SetTileId(int, int, int)
Sets the tile ID at the specified coordinates.
public void SetTileId(int x, int y, int tileId)
Parameters
ToArray()
Exports tile data to a flat array.
public int[] ToArray()
Returns
- int[]
Flat array of tile IDs
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.