Phaser API Documentation

  Version: 
addTilesetImage(tilesetName, [key], [tileWidth], [tileHeight], [tileMargin], [tileSpacing], [gid])

Description:

Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled editor.

Parameters:

name type arguments description
tilesetName string

The name of the tileset as specified in the map data.

key string <optional>

The key of the Phaser.Cache image used for this tileset. If undefined or null it will look for an image with a key matching the tilesetName parameter.

tileWidth number <optional>

The width of the tile (in pixels) in the Tileset Image. If not given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled JSON file.

tileHeight number <optional>

The height of the tiles (in pixels) in the Tileset Image. If not given it will default to the map's tileHeight value, or the tileHeight specified in the Tiled JSON file.

tileMargin number <optional>

The margin around the tiles in the sheet (in pixels). If not specified, it will default to 0 or the value specified in the Tiled JSON file.

tileSpacing number <optional>

The spacing between each the tile in the sheet (in pixels). If not specified, it will default to 0 or the value specified in the Tiled JSON file.

gid number <optional>

If adding multiple tilesets to a blank map, specify the starting GID this set will use here.

Returns:
Description:

Returns the Tileset object that was created or updated, or null if it failed.

Since: 3.0.0
Source: src/tilemaps/Tilemap.js (Line 378)