A rendered grid of tiles.
Constructor
new (tileset : TileType, width : Int, height : Int, tileWidth : Int, tileHeight : Int, tileMarginWidth : Int = 0, tileMarginHeight : Int = 0, tileOffsetX : Int = 0, tileOffsetY : Int = 0) : Void
Constructor.
Parameters:
tileset | The source tileset image. | |
width | Width of the tilemap, in pixels. | |
height | Height of the tilemap, in pixels. | |
tileWidth | Tile width. | |
tileHeight | Tile height. | |
tileMarginWidth | Tile horizontal spacing. | |
tileMarginHeight | Tile vertical spacing. |
Variables
Functions
clearRect (column : Int, row : Int, width : Int = 1, height : Int = 1) : Void
Clears the rectangular region of tiles.
Parameters:
column | First tile column. | |
row | First tile row. | |
width | Width in tiles. | |
height | Height in tiles. |
clearTile (column : Int, row : Int) : Void
Clears the tile at the position.
Parameters:
column | Tile column. | |
row | Tile row. |
createGrid (solidTiles : Array<Int>, grid : Grid) : Null<Grid>
Create a Grid object from this tilemap.
Parameters:
solidTiles | Array of tile indexes that should be solid. | |
grid | A grid to use instead of creating a new one, the function won't check if the grid is of correct dimension. |
Returns:
The grid with a tile solid if the tile index is in [solidTiles].
getTile (column : Int, row : Int) : Int
Gets the tile index at the position.
Parameters:
column | Tile column. | |
row | Tile row. |
Returns:
The tile index.
loadFrom2DArray (array : Array<Array<Int>>) : Void
Set the tiles from an array. The array must be of the same size as the Tilemap.
Parameters:
array | The array to load from. |
loadFromString (str : String, columnSep : String = ",", rowSep : String = "\n") : Void
Loads the Tilemap tile index data from a string. The implicit array should not be bigger than the Tilemap.
Parameters:
str | The string data, which is a set of tile values separated by the columnSep and rowSep strings. | |
columnSep | The string that separates each tile value on a row, default is ",". | |
rowSep | The string that separates each row of tiles, default is "\n". |
saveToString (columnSep : String = ",", rowSep : String = "\n") : String
Saves the Tilemap tile index data to a string.
Parameters:
columnSep | The string that separates each tile value on a row, default is ",". | |
rowSep | The string that separates each row of tiles, default is "\n". |
Returns:
The string version of the array.
setRect (column : Int, row : Int, width : Int = 1, height : Int = 1, index : Int = 0) : Void
Sets a rectangular region of tiles to the index.
Parameters:
column | First tile column. | |
row | First tile row. | |
width | Width in tiles. | |
height | Height in tiles. | |
index | Tile index. |
setTile (column : Int, row : Int, index : Int = 0) : Void
Sets the index of the tile at the position.
Parameters:
column | Tile column. | |
row | Tile row. | |
index | Tile index from the tileset to show. (Or -1 to show the tile as blank.) |
shiftTiles (columns : Int, rows : Int, wrap : Bool = false) : Void
Shifts all the tiles in the tilemap.
Parameters:
columns | Horizontal shift. | |
rows | Vertical shift. | |
wrap | If tiles shifted off the canvas should wrap around to the other side. |