Constructor
new TileLayer(position, size, tileInfoopt, renderOrderopt)
Create a tile layer object
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
position | Vector2 | World space position | ||
size | Vector2 | World space size | ||
tileInfo | TileInfo | <optional> | Default tile info for layer (used for size and texture) | |
renderOrder | number | <optional> | 0 | Objects are sorted by renderOrder |
- Source
Example
const tileLayer = new TileLayer(vec2(), vec2(200,100));
Extends
- CanvasLayer
Members
savedRenderSettings
- Source
Methods
drawTileData(layerPos, clearopt)
Draw the tile at a given position in the tile grid This can be used to clear out tiles when they are destroyed Tiles can also be redrawn if inside a redrawStart/End block
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
layerPos | Vector2 | |||
clear | boolean | <optional> | true | should the old tile be cleared out |
- Source
getData(layerPos) → {TileLayerData}
Get data at a given position in the array
Parameters:
Name | Type | Description |
---|---|---|
layerPos | Vector2 | Local position in array |
- Source
Returns:
- Type:
- TileLayerData
redraw()
Draw all the tile data to an offscreen canvas
- This may be slow in some browsers but only needs to be done once
- Source
redrawEnd()
Call to end the redraw process
- Source
redrawStart(clearopt)
Call to start the redraw process
- This can be used to manually update small parts of the level
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
clear | boolean | <optional> | false | Should it clear the canvas before drawing |
- Source
setData(layerPos, data, redrawopt)
Set data at a given position in the array
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
layerPos | Vector2 | Local position in array | ||
data | TileLayerData | Data to set | ||
redraw | boolean | <optional> | false | Force the tile to redraw if true |
- Source