LittleJS Tile Layer System
- Caches arrays of tiles to off screen canvas for fast rendering
- Unlimted 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
- Caches arrays of tiles to off screen canvas for fast rendering
- Unlimted 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
The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
- Source:
# (static) tileCollisionSize :Vector2
Size of the tile collision layer
Type:
- Source:
Methods
# (static) getTileCollisionData(pos) → {Number}
Get tile collision data
Parameters:
Name | Type | Description |
---|---|---|
pos |
Vector2 |
- Source:
Returns:
- Type
- Number
# (static) initTileCollision(size)
Clear and initialize tile collision
Parameters:
Name | Type | Description |
---|---|---|
size |
Vector2 |
- Source:
# (static) setTileCollisionData(pos, dataopt)
Set tile collision data
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pos |
Vector2 | |||
data |
Number |
<optional> |
0 |
- Source:
# (static) tileCollisionRaycast(posStart, posEnd, objectopt) → {Vector2}
Return the center of tile if any that is hit (this does not return the exact hit point)
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> |
new Vector2(1,1) | |
object |
EngineObject |
<optional> |
- Source:
Returns:
- Type
- Boolean