Uses a hash grid to determine collision, faster than using hundreds of Entities for tiled levels, etc.
Constructor
new (width : Int, height : Int, tileWidth : Int, tileHeight : Int, x : Int = 0, y : Int = 0) : Void
Constructor.
Parameters:
width | Width of the grid, in pixels. | |
height | Height of the grid, in pixels. | |
tileWidth | Width of a grid tile, in pixels. | |
tileHeight | Height of a grid tile, in pixels. | |
x | X offset of the grid. | |
y | Y offset of the grid. |
Variables
Functions
clearRect (column : Int = 0, row : Int = 0, width : Int = 1, height : Int = 1) : Void
Makes the rectangular region of tiles non-solid.
Parameters:
column | First column. | |
row | First row. | |
width | Columns to fill. | |
height | Rows to fill. |
clearTile (column : Int = 0, row : Int = 0) : Void
Makes the tile non-solid.
Parameters:
column | Tile column. | |
row | Tile row. |
collidePoint (cx : Float, cy : Float) : Bool
Checks collision against SlopedGrid from a point
Parameters:
cx | x-axis of the collision point | |
cy | y-axis of the collision point |
Returns:
If the point collides with SlopedGrid
getTile (column : Int = 0, row : Int = 0) : Tile
Gets the value of a tile.
Parameters:
column | Tile column. | |
row | Tile row. |
Returns:
tile value.
setRect (column : Int = 0, row : Int = 0, width : Int = 1, height : Int = 1, type : TileShape, slope : Float = 0, yOffset : Float = 0) : Void
Sets the value of a rectangle region of tiles.
Parameters:
column | First column. | |
row | First row. | |
width | Columns to fill. | |
height | Rows to fill. | |
type | The type of the tiles | |
slope | The slope of the tiles | |
yOffset | The y offset of the tiles |
setTile (column : Int = 0, row : Int = 0, type : TileShape, slope : Float = 0, yOffset : Float = 0) : Void
Sets the value of a tile.
Parameters:
column | Tile column. | |
row | Tile row. | |
type | The type of the tile | |
slope | The slope of the tile | |
yOffset | The y offset of the tile |