new Tileset(name, firstgid, width, height, margin, spacing, properties)
A Tile set is a combination of an image containing the tiles and collision data per tile. You should not normally instantiate this class directly.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The name of the tileset in the map data. |
firstgid |
number | The Tiled firstgid value. |
width |
number | Width of each tile in pixels. |
height |
number | Height of each tile in pixels. |
margin |
number | The amount of margin around the tilesheet. |
spacing |
number | The amount of spacing between each tile in the sheet. |
properties |
object | Tileset properties. |
- Source:
Members
-
columns
-
- Source:
Properties:
Name Type Description columnsnumber The number of columns in the tile sheet.
-
firstgid
-
- Default Value:
- firstgid
- Source:
Properties:
Name Type Description firstgidnumber The Tiled firstgid value.
-
image
-
- Source:
Properties:
Name Type Description imageobject The image used for rendering. This is a reference to the image stored in Phaser.Cache.
-
name
-
- Source:
Properties:
Name Type Description namestring The name of the Tileset.
-
properties
-
- Source:
Properties:
Name Type Description propertiesobject Tileset specific properties (typically defined in the Tiled editor).
-
rows
-
- Source:
Properties:
Name Type Description rowsnumber The number of rows in the tile sheet.
-
tileHeight
-
- Source:
Properties:
Name Type Description tileHeightnumber The height of a tile in pixels.
-
tileMargin
-
- Source:
Properties:
Name Type Description tileMarginnumber The margin around the tiles in the sheet.
-
tileSpacing
-
- Source:
Properties:
Name Type Description tileSpacingnumber The margin around the tiles in the sheet.
-
tileWidth
-
- Source:
Properties:
Name Type Description tileWidthnumber The width of a tile in pixels.
-
total
-
- Source:
Properties:
Name Type Description totalnumber The total number of tiles in the tilesheet.
Methods
-
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. checkTileIndex: function (index) {
return (this.tiles[index]); }- Type
- boolean
-
getTile(index) → {object}
-
Gets a Tile from this set.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
- Source:
Returns:
The tile object. getTile: function (index) {
return this.tiles[index]; },- Type
- object
-
getTileX(index) → {object}
-
Gets a Tile from this set.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
- Source:
Returns:
The tile object. getTileX: function (index) {
return this.tiles[index][0]; },- Type
- object
-
getTileY(index) → {object}
-
Gets a Tile from this set.
Parameters:
Name Type Description indexnumber The index of the tile within the set.
- Source:
Returns:
The tile object. getTileY: function (index) {
return this.tiles[index][1]; },- Type
- object
-
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: