A Tileset is a combination of a single image containing the tiles and a container for data about each tile.
new Tileset(name, firstgid, [tileWidth], [tileHeight], [tileMargin], [tileSpacing], [tileProperties], [tileData], [tileOffset])
name | type | arguments | Default | description |
---|---|---|---|---|
name | string |
The name of the tileset in the map data. |
||
firstgid | number |
The first tile index this tileset contains. |
||
tileWidth | number | <optional> | 32 |
Width of each tile (in pixels). |
tileHeight | number | <optional> | 32 |
Height of each tile (in pixels). |
tileMargin | number | <optional> | 0 |
The margin around all tiles in the sheet (in pixels). |
tileSpacing | number | <optional> | 0 |
The spacing between each tile in the sheet (in pixels). |
tileProperties | object | <optional> | {} |
Custom properties defined per tile in the Tileset. These typically are custom properties created in Tiled when editing a tileset. |
tileData | object | <optional> | {} |
Data stored per tile. These typically are created in Tiled when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. |
tileOffset | object | <optional> | {x: 0, y: 0} |
Tile texture drawing offset. |
The number of tile columns in the tileset.
The starting index of the first tile index this Tileset contains.
The gl texture used by the WebGL renderer.
The cached image that contains the individual tiles. Use setImage to set.
The name of the Tileset.
The number of tile rows in the the tileset.
The look-up table to specific tile image texture coordinates (UV in pixels). Each element contains the coordinates for a tile in an object of the form {x, y}.
Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within the Tileset collision editor. This is where collision objects and terrain are stored.
The height of each tile (in pixels). Use setTileSize to change.
The margin around the tiles in the sheet (in pixels). Use setSpacing
to change.
Controls the drawing offset from the tile origin. Defaults to 0x0, no offset.
Tileset-specific properties per tile that are typically defined in the Tiled editor in the Tileset editor.
The spacing between each the tile in the sheet (in pixels). Use setSpacing
to change.
The width of each tile (in pixels). Use setTileSize to change.
The total number of tiles in the tileset.
Returns true if and only if this Tileset contains the given tile index.
name | type | description |
---|---|---|
tileIndex | number |
The unique id of the tile across all tilesets in the map. |
Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not contained in this Tileset. This is typically defined within Tiled's tileset collision editor.
name | type | description |
---|---|---|
tileIndex | number |
The unique id of the tile across all tilesets in the map. |
Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained in this Tileset. This is typically defined in Tiled and will contain both Tileset collision info and terrain mapping.
name | type | description |
---|---|---|
tileIndex | number |
The unique id of the tile across all tilesets in the map. |
Get a tiles properties that are stored in the Tileset. Returns null if tile index is not contained in this Tileset. This is typically defined in Tiled under the Tileset editor.
name | type | description |
---|---|---|
tileIndex | number |
The unique id of the tile across all tilesets in the map. |
Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. Returns null if tile index is not contained in this Tileset.
name | type | description |
---|---|---|
tileIndex | number |
The unique id of the tile across all tilesets in the map. |
Object in the form { x, y } representing the top-left UV coordinate within the Tileset image.
Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.).
name | type | description |
---|---|---|
texture | Phaser.Textures.Texture |
The image that contains the tiles. |
This Tileset object.
Sets the tile margin and spacing and updates the tile data (rows, columns, etc.).
name | type | arguments | description |
---|---|---|---|
margin | number | <optional> |
The margin around the tiles in the sheet (in pixels). |
spacing | number | <optional> |
The spacing between the tiles in the sheet (in pixels). |
This Tileset object.
Sets the tile width & height and updates the tile data (rows, columns, etc.).
name | type | arguments | description |
---|---|---|---|
tileWidth | number | <optional> |
The width of a tile in pixels. |
tileHeight | number | <optional> |
The height of a tile in pixels. |
This Tileset object.
Updates tile texture coordinates and tileset data.
name | type | arguments | description |
---|---|---|---|
imageWidth | number |
The (expected) width of the image to slice. |
|
imageHeight | number |
The (expected) height of the image to slice. |
|
offsetX | number | <optional> |
The x offset in the source texture where the tileset starts. |
offsetY | number | <optional> |
The y offset in the source texture where the tileset starts. |
This Tileset object.