Class: CollisionMap

CollisionMap

Collision map is a 2D tilemap specifically designed for collision.
All the Entity instances will trace against this map during update.


new CollisionMap(tilesize, data)

Parameters:
Name Type Description
tilesize Number

Tile size in pixel

data Array

A 2D array representing the map.

Source:

Members


data :Array

Map data as a 2D array

Type:
  • Array
Source:

<readonly> height

Height of this map, in tile

Source:

tilesize :Number

Size of tiles in pixel

Type:
Source:

<readonly> width

Width of this map, in tile

Source:

Methods


getTile(r, q)

Get the tile index with its row and column number

Parameters:
Name Type Description
r Number

Row of this tile

q Number

Column of this tile

Source:
Returns:

Tile index

Type
Number

getTileAt(x, y)

Get the tile index at a specific position(in pixel)

Parameters:
Name Type Description
x Number

X position

y Number

Y position

Source:
Returns:

Tile index

Type
Number

setTile(r, q, tile)

Set the tile at the giving row and column

Parameters:
Name Type Description
r Number

Row of this tile

q Number

Column of this tile

tile Number

New tile index

Source:

setTileAt(x, y, tile)

Set the tile at a specific position

Parameters:
Name Type Description
x Number

X position

y Number

Y position

tile Number

New tile index

Source:

trace(coll, sx, sy, res)

Trace a collider against this map.

Parameters:
Name Type Description
coll Collider

Collider object.

sx Number

Movement on x-axis.

sy Number

Movement on y-axis.

res Object

Resolved movement result.

Source: