LittleJS Tile Layer System
- Caches arrays of tiles to off screen canvas for fast rendering
- Unlimited numbers of layers, allocates canvases as needed
- Interfaces with EngineObject for collision
- Collision layer is separate from visible layers
- It is recommended to have a visible layer that matches the collision
- Tile layers can be drawn to using their context with canvas2d
- Drawn directly to the main canvas without using WebGL
- Source
Members
(static) tileCollision :Array
The tile collision layer grid, use setTileCollisionData and getTileCollisionData to access
Type:
- Array
- Source
(static) tileCollisionSize :Vector2
Size of the tile collision layer 2d grid
Type:
- Source
Methods
(static) getTileCollisionData(pos) → {Number}
Get tile collision data for a given cell in the grid
Parameters:
Name | Type | Description |
---|---|---|
pos | Vector2 |
- Source
Returns:
- Type:
- Number
(static) initTileCollision(size)
Clear and initialize tile collision
Parameters:
Name | Type | Description |
---|---|---|
size | Vector2 | width and height of tile collision 2d grid |
- Source
(static) setTileCollisionData(pos, dataopt)
Set tile collision data for a given cell in the grid
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
data | Number | <optional> | 0 |
- Source
(static) tileCollisionRaycast(posStart, posEnd, objectopt) → {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 | Description |
---|---|---|---|
posStart | Vector2 | ||
posEnd | Vector2 | ||
object | EngineObject | <optional> |
- Source
Returns:
- Type:
- Vector2
(static) tileCollisionTest(pos, sizeopt, objectopt) → {Boolean}
Check if collision with another object should occur
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos | Vector2 | |||
size | Vector2 | <optional> | (0,0) | |
object | EngineObject | <optional> |
- Source
Returns:
- Type:
- Boolean