Create a tile layer object
pos Vector2World space position
size Vector2World space size
tileInfo TileInfo optionalTile info for layer, 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
Solid layers block objects and particles, the solidOnly tests skip the others
The tiles set one way, by tile index, and the way each can be passed
through, see setOneWay
In the light system's shadow pass, cast only from the cells with collision, drawn
as the layer shows them, so a floor in the same layer stays lit; false casts every tile
Clear tile collision data for a given cell in the layer
layerPos Vector2
Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
The point will be inside the colliding tile if it hits (may have a tiny shift)
posStart Vector2posEnd Vector2callbackObject EngineObject|TileCollisionCallback optionalCallback, engine object, or undefined
normal Vector2 optionalOptional normal of the surface hit
Check if collision with another object should occur
pos Vector2size Vector2 optional, default vec2()callbackObject EngineObject|TileCollisionCallback optionalCallback, engine object, or undefined
Get tile collision data for a given cell in the layer
layerPos Vector2
Clear and initialize tile collision, the size is the layer's own, the tile data and canvas keep it
size Vector2width and height of tile collision 2d grid
Draw this layer's shadow shape: the cells with collision in the part the shadow map covers, each row of
them in one draw from that part of the layer's texture, so see through pixels in a tile cast nothing;
every tile when shadowSolidOnly is off, or when the layer is turned or mirrored
Set tile collision data for a given cell in the layer
layerPos Vector2data number optional, default 1
Make the cells that draw a tile one way, like a platform jumped up through and landed on: an object, a
particle or a ray passes through moving that way, and the tile blocks only what was wholly on its far side
before it moved, the side it is passed toward; turned and mirrored as each cell's tile is, so a platform turned
a quarter is one way to the side
- A moving object is not stopped or asked through collideWithTile until the tile would block it, so a
collideWithTile that returns false lets it drop through
- tileCollisionTest with an object goes by the object's pos, a raycast by its start, and a test with no object
or with a callback finds every one way tile solid
tile numberThe tile index, as tile() and TileLayerData take it
direction Vector2 optionalUp, down, left or right, the way it can be passed through: vec2(0, 1), the
default, is a platform landed on from above; layer.oneWayTiles.delete(tile) makes the tile solid again
layer.setOneWay(5); // tile 5 is a platform, jumped up through and stood on