Creates a new Tilemap Layer that renders the LayerData associated with the given
layerID
. The currently selected layer in the map is set to this new layer.
The layerID
is important. If you've created your map in Tiled then you can get this by
looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and
look at the layers[].name value. Either way it must match.
Prior to v3.50.0 this method was called createDynamicLayer
.
name | type | arguments | description |
---|---|---|---|
layerID | number | string |
The layer array index value, or if a string is given, the layer name from Tiled. |
|
tileset | string | Array.<string> | Phaser.Tilemaps.Tileset | Array.<Phaser.Tilemaps.Tileset> |
The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. |
|
x | number | <optional> |
The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. |
y | number | <optional> |
The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. |
Returns the new layer was created, or null if it failed.