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
Is this layer using a webgl texture?
Default tile info for layer
Clear data at a given position in the array
layerPos Vector2Local position in array
redraw boolean optional, default falseForce the tile to redraw if true
Clear a rectangle in layer space
pos Vector2position in pixel coordinates
size Vector2
Draw a rectangle in layer space
pos Vector2size Vector2color Color optional, default WHITEColor to modulate with
angle number optional, default 0Angle to rotate by
Draw textured tile in layer space
pos Vector2Position in pixel coordinates
size Vector2 optional, default vec2(1)Size of the tile
tileInfo TileInfo optionalTile info to use, untextured if undefined
color Color optional, default WHITEColor to modulate with
angle number optional, default 0Angle to rotate by
mirror boolean optionalIs the image flipped left to right?
additiveColor Color optionalAdditive color to be applied if any
Draw a rectangle onto the layer canvas in world space
pos Vector2size Vector2 optional, default vec2(1)color Color optional, default WHITEangle number optional
Draw a tile onto the layer canvas in world space
pos Vector2size Vector2 optional, default vec2(1)tileInfo TileInfo optionalcolor Color optional, default WHITEangle number optional, default 0mirror boolean optional, default false
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 end the redraw process
Call to start the redraw process
- 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 optional, default falseForce the tile to redraw if true