Skip to content

Commit 0ee08b7

Browse files
committed
Jsdocs: ParseToTilemap
1 parent 382d8ed commit 0ee08b7

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

v3/src/gameobjects/tilemap/ParseToTilemap.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,28 @@ var Parse = require('./parsers/Parse');
33
var MapData = require('./mapdata/MapData');
44
var Tilemap = require('./Tilemap');
55

6-
// Parse from key or data and create a Tilemap. If neither is given, make an empty Tilemap.
6+
/**
7+
* Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When
8+
* loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from
9+
* a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For
10+
* an empty map, you should specify tileWidth, tileHeight, width & height.
11+
*
12+
* @param {Scene} scene - [description]
13+
* @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data.
14+
* @param {number} [tileWidth=32] - The width of a tile in pixels.
15+
* @param {number} [tileHeight=32] - The height of a tile in pixels.
16+
* @param {number} [width=10] - The width of the map in tiles.
17+
* @param {number} [height=10] - The height of the map in tiles.
18+
* @param {array} [data] - Instead of loading from the cache, you can also load directly from a 2D
19+
* array of tile indexes.
20+
* @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the
21+
* map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty
22+
* location will get a Tile object with an index of -1. If you've a large sparsely populated map and
23+
* the tile data doesn't need to change then setting this value to `true` will help with memory
24+
* consumption. However if your map is small or you need to update the tiles dynamically, then leave
25+
* the default value set.
26+
* @returns {Tilemap}
27+
*/
728
var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull)
829
{
930
if (tileWidth === undefined) { tileWidth = 32; }

v3/src/gameobjects/tilemap/TilemapCreator.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ var ParseToTilemap = require('./ParseToTilemap');
44
// When registering a factory function 'this' refers to the GameObjectCreator context.
55

66
/**
7-
* Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided.
7+
* Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data
8+
* provided. When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When
9+
* parsing from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the
10+
* map data. For an empty map, you should specify tileWidth, tileHeight, width & height.
811
*
912
* @param {object} [config] - The config options for the Tilemap.
1013
* @param {string} [config.key] - The key in the Phaser cache that corresponds to the loaded tilemap

v3/src/gameobjects/tilemap/TilemapFactory.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ var ParseToTilemap = require('./ParseToTilemap');
1111

1212
/**
1313
* Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided.
14+
* When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing
15+
* from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map
16+
* data. For an empty map, you should specify tileWidth, tileHeight, width & height.
1417
*
1518
* @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data.
1619
* @param {number} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the

0 commit comments

Comments
 (0)