Tilemap#createFromTiles()

createFromTiles(tiles, replacements, key, layer, group, properties) → {integer}

Creates a Sprite for every object matching the given tile indexes in the map data.
You can specify the group that the Sprite will be created in. If none is given it will be created in the World.
You can optional specify if the tile will be replaced with another after the Sprite is created. This is useful if you want to lay down special
tiles in a level that are converted to Sprites, but want to replace the tile itself with a floor tile or similar once converted.

Parameters
Name Type Argument Default Description
tiles integer | Array

The tile index, or array of indexes, to create Sprites from.

replacements integer | Array

The tile index, or array of indexes, to change a converted tile to. Set to null to not change.

key string

The Game.cache key of the image that this Sprite will use.

layer number | string | Phaser.TilemapLayer <optional>

The layer to operate on.

group Phaser.Group <optional>
Phaser.World

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

properties object <optional>

An object that contains the default properties for your newly created Sprite. This object will be iterated and any matching Sprite property will be set.

Returns
integer -

The number of Sprites that were created.

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

Please login to continue.