new TileMap(tileSet, pWidth, pHeight, pTileWidth, pTileHeight, pTypes, pZIndex, pCollide)
Represent a tile map for build tiled games.
No need to add the tilemap to the state, it's done when the tilemap is
loaded.
By default a tilemap does not collide to anything.
Parameters:
Name | Type | Description |
---|---|---|
tileSet |
FM.ImageAsset | Image of the tile set in the order of the data given. |
pWidth |
int | The number of tiles constituing the width of the tile map. |
pHeight |
int | The number of tiles constituing the height of the tile map. |
pTileWidth |
int | The width of a tile. |
pTileHeight |
int | The height of a tile. |
pTypes |
Array | The types to set the tiles of the tile map to. |
pZIndex |
int | The depth of the tiles of the tile map. |
pCollide |
boolean | Whether the tile map should collide or not. |
- Source:
Methods
-
allowCollisions()
-
Allow collisions for this tile map.
- Source:
-
canCollide() → {boolean}
-
Check if this tile map can collide.
- Source:
Returns:
Whether this tile map can collide or not.- Type
- boolean
-
destroy()
-
Destroy the tile map and its objects.
- Source:
-
getData() → {Array}
-
Retrive the 2D array of tile IDs.
- Source:
Returns:
The list of tile IDs of tile map.- Type
- Array
-
getHeight() → {int}
-
Get the height of the map.
- Source:
Returns:
The number of tiles constituing the height of the tile map.- Type
- int
-
getTileHeight() → {int}
-
Get the height of a tile.
- Source:
Returns:
The height of a tile.- Type
- int
-
getTileId(pX, pY) → {int}
-
Retrieve the tile ID associated to a given position.
Parameters:
Name Type Description pX
int The x position of the tile to retrieve. pY
int The y position of the tile to retrieve. - Source:
Returns:
The ID of the tile at the given position.- Type
- int
-
getTileSet() → {Image}
-
Retrive the tile set.
- Source:
Returns:
The tile set.- Type
- Image
-
getTileWidth() → {int}
-
Get the width of a tile.
- Source:
Returns:
The width of a tile.- Type
- int
-
getWidth() → {int}
-
Get the width of the map.
- Source:
Returns:
The number of tiles constituing the width of the tile map.- Type
- int
-
getZIndex() → {int}
-
Get the z-index of the map.
- Source:
Returns:
The depth of the tiles of the tile map.- Type
- int
-
hasType() → {boolean}
-
Check if this tile map has a specified type.
- Source:
Returns:
Whether this tile map has the given type or not.- Type
- boolean
-
load(pData)
-
Load the tilemap.
Parameters:
Name Type Description pData
string Comma and line return sparated string of numbers representing the position and type of tiles. - Source:
-
preventCollisions()
-
Prevent collisions for this tile map.
- Source: