forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTilemapCreator.js
More file actions
38 lines (35 loc) · 1.21 KB
/
Copy pathTilemapCreator.js
File metadata and controls
38 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var GameObjectCreator = require('../gameobjects/GameObjectCreator');
var ParseToTilemap = require('./ParseToTilemap');
/**
* Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided.
* When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing
* from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map
* data. For an empty map, you should specify tileWidth, tileHeight, width & height.
*
* @method Phaser.GameObjects.GameObjectCreator#tilemap
* @since 3.0.0
*
* @param {Phaser.Types.Tilemaps.TilemapConfig} [config] - The config options for the Tilemap.
*
* @return {Phaser.Tilemaps.Tilemap}
*/
GameObjectCreator.register('tilemap', function (config)
{
// Defaults are applied in ParseToTilemap
var c = (config !== undefined) ? config : {};
return ParseToTilemap(
this.scene,
c.key,
c.tileWidth,
c.tileHeight,
c.width,
c.height,
c.data,
c.insertNull
);
});