GameObjectFactory#tilemap()

tilemap(key, tileWidth, tileHeight, width, height) → {Phaser.Tilemap}

Creates a new Phaser.Tilemap object.

The map can either be populated with data from a Tiled JSON file or from a CSV file.
To do this pass the Cache key as the first parameter. When using Tiled data you need only provide the key.
When using CSV data you must provide the key and the tileWidth and tileHeight parameters.
If creating a blank tilemap to be populated later, you can either specify no parameters at all and then use Tilemap.create or pass the map and tile dimensions here.
Note that all Tilemaps use a base tile size to calculate dimensions from, but that a TilemapLayer may have its own unique tile size that overrides it.

Parameters
Name Type Argument Default Description
key string <optional>

The key of the tilemap data as stored in the Cache. If you're creating a blank map either leave this parameter out or pass null.

tileWidth number <optional>
32

The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data.

tileHeight number <optional>
32

The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data.

width number <optional>
10

The width of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this.

height number <optional>
10

The height of the map in tiles. If this map is created from Tiled or CSV data you don't need to specify this.

Returns

The newly created tilemap object.

Source code: gameobjects/GameObjectFactory.js (Line 461)
doc_phaser
2017-02-14 10:48:48
Comments
Leave a Comment

Please login to continue.