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 | Argument | Default | Description |
|---|---|---|---|---|
name |
string | The name of the tileset in the map data. |
||
firstgid |
number | The Tiled firstgid value. In non-Tiled data this should be considered the starting index value of the first tile in this set. |
||
width |
number |
<optional> |
32 | Width of each tile in pixels. |
height |
number |
<optional> |
32 | Height of each tile in pixels. |
margin |
number |
<optional> |
0 | The amount of margin around the tilesheet. |
spacing |
number |
<optional> |
0 | The amount of spacing between each tile in the sheet. |
properties |
object |
<optional> |
Tileset properties. |
- Source:
Members
-
columns
-
- Source:
Properties:
Name Type Description columnsnumber The number of columns in the tile sheet.
-
firstgid
-
- Source:
Properties:
Name Type Description firstgidnumber The Tiled firstgid value. In non-Tiled data this should be considered the starting index value of the first tile in this set.
-
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 tileset.
-
tileSpacing
-
- Source:
Properties:
Name Type Description tileSpacingnumber The spacing in pixels between each tile in the tileset.
-
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
-
draw(context, x, y, index)
-
Draws a tile from this Tileset at the given coordinates on the context.
Parameters:
Name Type Description contextHTMLCanvasContext The context to draw the tile onto.
xnumber The x coordinate to draw to.
ynumber The y coordinate to draw to.
indexnumber The index of the tile within the set to draw.
- Source:
-
setImage(image)
-
Adds a reference from this Tileset to an Image stored in the Phaser.Cache.
Parameters:
Name Type Description imageImage The image this tileset will use to draw with.
- 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: