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>
2023-01-02 17:36:27 +00:00
* @copyright 2013-2023 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
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
2022-02-28 14:29:51 +00:00
*
2019-05-09 11:39:19 +00:00
* @param {Phaser.Types.Tilemaps.TilemapConfig} [config] - The config options for the Tilemap.
2022-02-28 14:29:51 +00:00
*
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
);
});