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 image
object The image used for rendering.
-
key
-
- Source:
Properties:
Name Type Description key
string The cache ID.
-
margin
-
- Source:
Properties:
Name Type Description tileMargin
number The margin around the tiles in the sheet.
-
spacing
-
- Source:
Properties:
Name Type Description tileSpacing
number The margin around the tiles in the sheet.
-
tileHeight
-
- Source:
Properties:
Name Type Description tileHeight
number The height of a tile in pixels.
-
tiles
-
- Source:
Properties:
Name Type Description tiles
array An array of the tile collision data.
-
tileWidth
-
- Source:
Properties:
Name Type Description tileWidth
number The width of a tile in pixels.
-
<readonly> total
-
- Source:
Properties:
Name Type Description total
number The total number of tiles in this Tileset.
Methods
-
addTile(tile)
-
Adds a Tile into this set.
Parameters:
Name Type Description tile
Phaser.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 index
number 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 index
number 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 index
number 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 index
number The index of the tile within the set.
left
boolean Should the tile collide on the left?
right
boolean Should the tile collide on the right?
up
boolean Should the tile collide on the top?
down
boolean 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 start
number The index to start setting the collision data on.
stop
number The index to stop setting the collision data on.
left
boolean Should the tile collide on the left?
right
boolean Should the tile collide on the right?
up
boolean Should the tile collide on the top?
down
boolean Should the tile collide on the bottom?
- Source:
-
setSpacing(tileMargin, tileSpacing)
-
Sets tile spacing and margins.
Parameters:
Name Type Argument Description tileMargin
number <optional>
The margin around the tiles in the sheet.
tileSpacing
number <optional>
The spacing between the tiles in the sheet.
- Source: