Tilemap#Tilemap

new Tilemap(game, key, tileWidth, tileHeight, width, height)

Creates a new Phaser.Tilemap object. The map can either be populated with data from a Tiled JSON file or from a CSV file.

Tiled is a free software package specifically for creating tile maps, and is available from http://www.mapeditor.org

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.
A Tile map is rendered to the display using a TilemapLayer. It is not added to the display list directly itself.
A map may have multiple layers. You can perform operations on the map data such as copying, pasting, filling and shuffling the tiles around.

Parameters
Name Type Argument Default Description
game Phaser.Game

Game reference to the currently running game.

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.

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

Please login to continue.