LittleJS Tile Layer System
- Caches arrays of tiles to off screen canvas for fast rendering
- Unlimited numbers of layers, allocates canvases as needed
- Tile layers can be drawn to using their context with canvas2d
- Tile layers can also have collision with EngineObjects
- Source
Members
(static, constant) tileCollisionLayers :Array.<TileCollisionLayer>
Keep track of all tile layers with collision
Type:
- Array.<TileCollisionLayer>
- Source
Methods
(static) tileCollisionGetData(pos) → {number}
Get tile collision data for a given cell in the grid
Parameters:
Name | Type | Description |
---|---|---|
pos | Vector2 |
- Source
Returns:
- Type:
- number
(static) tileCollisionLoad(tileMapData, tileInfoopt, renderOrderopt, collisionLayeropt, drawopt) → {Array.<TileCollisionLayer>}
Load tile layers from exported data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tileMapData | Object | Level data from exported data | ||
tileInfo | TileInfo | <optional> | Default tile info (used for size and texture) | |
renderOrder | number | <optional> | 0 | Render order of the top layer |
collisionLayer | number | <optional> | Layer to use for collision if any | |
draw | boolean | <optional> | true | Should the layer be drawn automatically |
- Source
Returns:
- Type:
- Array.<TileCollisionLayer>
(static) tileCollisionRaycast(posStart, posEnd, objectopt, solidOnlyopt) → {Vector2}
Return the center of first tile hit, undefined if nothing was hit. This does not return the exact intersection, but the center of the tile hit.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
posStart | Vector2 | |||
posEnd | Vector2 | |||
object | EngineObject | <optional> | An object or undefined for generic test | |
solidOnly | boolean | <optional> | true | Only check solid layers if true |
- Source
Returns:
- Type:
- Vector2
(static) tileCollisionTest(pos, sizeopt, objectopt, solidOnlyopt) → {TileCollisionLayer}
Check if a tile layer collides with another object
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | <optional> | (0,0) | |
object | EngineObject | <optional> | An object or undefined for generic test | |
solidOnly | boolean | <optional> | true | Only check solid layers if true |
- Source
Returns:
- Type:
- TileCollisionLayer