new Tileset(image, key, tileWidth, tileHeight, tileMargin, tileSpacing)
A Tile set is a combination of an image containing the tiles and collision data per tile.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
image |
Image | The Image object from the Cache. |
|
key |
string | The key of the tileset in the cache. |
|
tileWidth |
number | The width of the tile in pixels. |
|
tileHeight |
number | The height of the tile in pixels. |
|
tileMargin |
number |
<optional> |
The margin around the tiles in the sheet. |
tileSpacing |
number |
<optional> |
The spacing between the tiles in the sheet. |
- Source:
Members
-
image
-
- Source:
Properties:
Name Type Description imageobject The image used for rendering.
-
key
-
- Source:
Properties:
Name Type Description keystring The cache ID.
-
margin
-
- Source:
Properties:
Name Type Description tileMarginnumber The margin around the tiles in the sheet.
-
spacing
-
- Source:
Properties:
Name Type Description tileSpacingnumber The margin around the tiles in the sheet.
-
tileHeight
-
- Source:
Properties:
Name Type Description tileHeightnumber The height of a tile in pixels.
-
tiles
-
- Source:
Properties:
Name Type Description tilesarray An array of the tile collision data.
-
tileWidth
-
- Source:
Properties:
Name Type Description tileWidthnumber The width of a tile in pixels.
-
<readonly> total
-
- Source:
Properties:
Name Type Description totalnumber The total number of tiles in this Tileset.
Methods
-
addTile(tile)
-
Adds a Tile into this set.
Parameters:
Name Type Description tilePhaser.Tile The tile to add to this set.
- Source:
-
canCollide(index) → {boolean}
-
Checks if the tile at the given index can collide.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
- Source:
Returns:
True or false depending on the tile collision or null if no tile was found at the given index.
- Type
- boolean
-
checkTileIndex(index) → {boolean}
-
Checks if the tile at the given index exists.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
- Source:
Returns:
True if a tile exists at the given index otherwise false.
- Type
- boolean
-
getTile(index) → {Phaser.Tile}
-
Gets a Tile from this set.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
- Source:
Returns:
The tile.
- Type
- Phaser.Tile
-
setCollision(index, left, right, up, down)
-
Sets collision values on a tile in the set.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
leftboolean Should the tile collide on the left?
rightboolean Should the tile collide on the right?
upboolean Should the tile collide on the top?
downboolean Should the tile collide on the bottom?
- Source:
-
setCollisionRange(start, stop, left, right, up, down)
-
Sets collision values on a range of tiles in the set.
Parameters:
Name Type Description startnumber The index to start setting the collision data on.
stopnumber The index to stop setting the collision data on.
leftboolean Should the tile collide on the left?
rightboolean Should the tile collide on the right?
upboolean Should the tile collide on the top?
downboolean Should the tile collide on the bottom?
- Source:
-
setSpacing(tileMargin, tileSpacing)
-
Sets tile spacing and margins.
Parameters:
Name Type Argument Description tileMarginnumber <optional>
The margin around the tiles in the sheet.
tileSpacingnumber <optional>
The spacing between the tiles in the sheet.
- Source: