Collision tilemap class. A collision tilemap shape is a grid of equal-sized cells that can either block or not (+ have collision flags). Its the most efficient (both memory and CPU) way to implement grid based / tilemap collision.
Kind: global class
RectangleShape
Array.<RectangleShape>
Create the collision tilemap.
Param | Type | Description |
---|---|---|
offset | Vector2 |
Tilemap top-left corner. |
gridSize | Vector2 |
Number of tiles on X and Y axis. |
tileSize | Vector2 |
The size of a single tile. |
borderThickness | Number |
Set a border collider with this thickness. |
Kind: instance property of TilemapShape
Set the state of a tile.
Kind: instance method of TilemapShape
Param | Type | Description |
---|---|---|
index | Vector2 |
Tile index. |
haveCollision | Boolean |
Does this tile have collision? |
collisionFlags | Number |
Optional collision flag to set for this tile. |
RectangleShape
Get the collision shape of a tile at a given position.
Kind: instance method of TilemapShape
Returns: RectangleShape
- Collision shape at this position, or null if not set.
Param | Type | Description |
---|---|---|
position | Vector2 |
Position to get tile at. |
Iterate all tiles in given region, represented by a rectangle.
Kind: instance method of TilemapShape
Param | Type | Description |
---|---|---|
region | Rectangle |
Rectangle to get tiles for. |
callback | function |
Method to invoke for every tile. Return false to break iteration. |
Array.<RectangleShape>
Get all tiles in given region, represented by a rectangle.
Kind: instance method of TilemapShape
Returns: Array.<RectangleShape>
- Array with rectangle shapes or empty if none found.
Param | Type | Description |
---|---|---|
region | Rectangle |
Rectangle to get tiles for. |
Kind: instance method of TilemapShape
Kind: instance method of TilemapShape
Kind: instance method of TilemapShape
Kind: instance method of TilemapShape