phaser/src/tilemaps/TilemapCreator.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2019-01-15 16:20:22 +00:00
* @copyright 2019 Photon Storm Ltd.
2018-02-12 16:01:20 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
2018-02-07 17:10:01 +00:00
var GameObjectCreator = require('../gameobjects/GameObjectCreator');
var ParseToTilemap = require('./ParseToTilemap');
2017-11-29 19:46:29 +00:00
/**
* 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.
2017-11-29 19:46:29 +00:00
*
2018-02-07 23:27:01 +00:00
* @method Phaser.GameObjects.GameObjectCreator#tilemap
* @since 3.0.0
*
2019-02-13 16:06:00 +00:00
* @param {Phaser.Tilemaps.Types.TilemapConfig} [config] - The config options for the Tilemap.
2018-02-07 23:27:01 +00:00
*
* @return {Phaser.Tilemaps.Tilemap}
2017-11-29 19:46:29 +00:00
*/
GameObjectCreator.register('tilemap', function (config)
{
2017-11-29 19:46:29 +00:00
// Defaults are applied in ParseToTilemap
2018-02-07 23:27:01 +00:00
var c = (config !== undefined) ? config : {};
return ParseToTilemap(
this.scene,
c.key,
c.tileWidth,
c.tileHeight,
c.width,
c.height,
c.data,
c.insertNull
);
});