Create a tile layer object
pos Vector2World space position
size Vector2World space size
tileInfo TileInfo optionalDefault tile info for layer (used for size and texture), tile() by default, none when no image is loaded
renderOrder number optional, default 0Objects are sorted by renderOrder
useWebGL boolean optional, default trueShould this layer use WebGL for rendering
const tileLayer = new TileLayer(vec2(), vec2(200,100));
Array of tile data for the layer
Show this layer's bounds and values when the debug overlay's Debug Tiles is on,
turn it off for layers that only add noise
Default tile info for layer
Clear data at a given position in the array
layerPos Vector2Local position in array
redraw boolean optionalTrue draws the cell now, false leaves it as drawn, left out draws it on the
next render
Draw a tile onto the layer in world space, over the cells waiting to be drawn
pos Vector2size Vector2 optional, default vec2(1)tileInfo TileInfo optionalcolor Color optional, default WHITEangle number optionalmirror boolean optional
Draw the tile at a given position in the tile layer
This can be used to clear out tiles when they are destroyed
Tiles can also be redrawn if inside a redrawStart/End block
layerPos Vector2clear boolean optional, default trueshould the old tile be cleared out
Get data at a given position in the array
layerPos Vector2Local position in array
Called after this layer is redrawn, does nothing by default
Draw all the tile data to an offscreen canvas
- This may be slow if not using webgl but only needs to be done once
Call to start the redraw process, after what is waiting is drawn
- This can be used to manually update parts of the level
clear boolean optional, default falseShould it clear the canvas before drawing
Draw the tile at a given position in the tile layer
This can be used to clear tiles when they are destroyed
For better performance use drawTileData inside a redrawStart/End block
layerPos Vector2clear boolean optional, default trueshould the old tile be cleared
Set data at a given position in the array
layerPos Vector2Local position in array
data TileLayerDataData to set
redraw boolean optionalTrue draws the cell now, false leaves it as drawn, left out draws it
on the next render, or now inside the layer's own redraw; when more than
half the cells wait the whole layer is drawn again, clearing paint too
Create WebGL texture if necessary and copy layer canvas to it, which counts as drawn, so a picture the game
drew onto the canvas is not drawn over with the tiles on the first render