Tilemap#createLayer()

createLayer(layer, width, height, group) → {Phaser.TilemapLayer}

Creates a new TilemapLayer object. By default TilemapLayers are fixed to the camera.
The layer parameter 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.
If you wish to create a blank layer to put your own tiles on then see Tilemap.createBlankLayer.

Parameters
Name Type Argument Description
layer number | string

The layer array index value, or if a string is given the layer name, within the map data that this TilemapLayer represents.

width number <optional>

The rendered width of the layer, should never be wider than Game.width. If not given it will be set to Game.width.

height number <optional>

The rendered height of the layer, should never be wider than Game.height. If not given it will be set to Game.height.

group Phaser.Group <optional>

Optional Group to add the object to. If not specified it will be added to the World group.

Returns

The TilemapLayer object. This is an extension of Phaser.Sprite and can be moved around the display list accordingly.

Source code: tilemap/Tilemap.js (Line 561)
doc_phaser
2017-02-14 11:15:12
Comments
Leave a Comment

Please login to continue.