Skip to content

Commit 6283a8d

Browse files
committed
Added jsdocs
1 parent 97bb52f commit 6283a8d

18 files changed

Lines changed: 151 additions & 18 deletions

src/tilemaps/parsers/Parse.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
var Formats = require('../Formats');
22
var Parse2DArray = require('./Parse2DArray');
33
var ParseCSV = require('./ParseCSV');
4-
var ParseTiledJSON = require('./tiled/');
5-
var ParseWeltmister = require('./impact/');
4+
var ParseJSONTiled = require('./tiled/ParseJSONTiled');
5+
var ParseWeltmeister = require('./impact/ParseWeltmeister');
66

77
/**
88
* Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format
99
* is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth &
1010
* tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from
1111
* the map data.
1212
*
13+
* @function Phaser.Tilemaps.Parsers.Parse
14+
* @since 3.0.0
15+
*
1316
* @param {string} name - The name of the tilemap, used to set the name on the MapData.
1417
* @param {integer} mapFormat - See ../Formats.js.
1518
* @param {integer[][]|string|object} data - 2D array, CSV string or Tiled JSON object.
@@ -23,12 +26,14 @@ var ParseWeltmister = require('./impact/');
2326
* the tile data doesn't need to change then setting this value to `true` will help with memory
2427
* consumption. However if your map is small or you need to update the tiles dynamically, then leave
2528
* the default value set.
29+
*
30+
* @return {[type]} [description]
2631
*/
2732
var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull)
2833
{
2934
var newMap;
3035

31-
switch(mapFormat)
36+
switch (mapFormat)
3237
{
3338
case (Formats.ARRAY_2D):
3439
newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull);
@@ -37,10 +42,10 @@ var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull)
3742
newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull);
3843
break;
3944
case (Formats.TILED_JSON):
40-
newMap = ParseTiledJSON(name, data, insertNull);
45+
newMap = ParseJSONTiled(name, data, insertNull);
4146
break;
4247
case (Formats.WELTMEISTER):
43-
newMap = ParseWeltmister(name, data, insertNull);
48+
newMap = ParseWeltmeister(name, data, insertNull);
4449
break;
4550
default:
4651
console.warn('Unrecognized tilemap data format: ' + mapFormat);

src/tilemaps/parsers/Parse2DArray.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ var Tile = require('../Tile');
66
/**
77
* Parses a 2D array of tile indexes into a new MapData object with a single layer.
88
*
9+
* @function Phaser.Tilemaps.Parsers.Parse2DArray
10+
* @since 3.0.0
11+
*
912
* @param {string} name - The name of the tilemap, used to set the name on the MapData.
1013
* @param {integer[][]} data - 2D array, CSV string or Tiled JSON object.
1114
* @param {integer} tileWidth - The width of a tile in pixels.
@@ -16,6 +19,8 @@ var Tile = require('../Tile');
1619
* the tile data doesn't need to change then setting this value to `true` will help with memory
1720
* consumption. However if your map is small or you need to update the tiles dynamically, then leave
1821
* the default value set.
22+
*
23+
* @return {[type]} [description]
1924
*/
2025
var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull)
2126
{

src/tilemaps/parsers/ParseCSV.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ var Parse2DArray = require('./Parse2DArray');
44
/**
55
* Parses a CSV string of tile indexes into a new MapData object with a single layer.
66
*
7+
* @function Phaser.Tilemaps.Parsers.ParseCSV
8+
* @since 3.0.0
9+
*
710
* @param {string} name - The name of the tilemap, used to set the name on the MapData.
811
* @param {string} data - CSV string of tile indexes.
912
* @param {integer} tileWidth - The width of a tile in pixels.
@@ -14,6 +17,8 @@ var Parse2DArray = require('./Parse2DArray');
1417
* the tile data doesn't need to change then setting this value to `true` will help with memory
1518
* consumption. However if your map is small or you need to update the tiles dynamically, then leave
1619
* the default value set.
20+
*
21+
* @return {[type]} [description]
1722
*/
1823
var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull)
1924
{

src/tilemaps/parsers/impact/ParseTileLayers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
var LayerData = require('../../mapdata/LayerData');
22
var Tile = require('../../Tile');
33

4+
/**
5+
* [description]
6+
*
7+
* @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers
8+
* @since 3.0.0
9+
*
10+
* @param {object} json - [description]
11+
* @param {boolean} insertNull - [description]
12+
*
13+
* @return {array} [description]
14+
*/
415
var ParseTileLayers = function (json, insertNull)
516
{
617
var tileLayers = [];

src/tilemaps/parsers/impact/ParseTilesets.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
var Tileset = require('../../Tileset');
22

3+
/**
4+
* [description]
5+
*
6+
* @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets
7+
* @since 3.0.0
8+
*
9+
* @param {object} json - [description]
10+
*
11+
* @return {array} [description]
12+
*/
313
var ParseTilesets = function (json)
414
{
515
var tilesets = [];

src/tilemaps/parsers/impact/index.js renamed to src/tilemaps/parsers/impact/ParseWeltmeister.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
var Formats = require('../../Formats');
22
var MapData = require('../../mapdata/MapData');
3-
var ParseTilesets = require('./ParseTilesets');
43
var ParseTileLayers = require('./ParseTileLayers');
4+
var ParseTilesets = require('./ParseTilesets');
55

66
/**
77
* Parses a Weltmeister JSON object into a new MapData object.
88
*
9+
* @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister
10+
* @since 3.0.0
11+
*
912
* @param {string} name - The name of the tilemap, used to set the name on the MapData.
1013
* @param {object} json - The Weltmeister JSON object.
1114
* @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map
@@ -14,6 +17,8 @@ var ParseTileLayers = require('./ParseTileLayers');
1417
* the tile data doesn't need to change then setting this value to `true` will help with memory
1518
* consumption. However if your map is small or you need to update the tiles dynamically, then leave
1619
* the default value set.
20+
*
21+
* @return {object|null} [description]
1722
*/
1823
var ParseWeltmeister = function (name, json, insertNull)
1924
{
@@ -25,6 +30,7 @@ var ParseWeltmeister = function (name, json, insertNull)
2530

2631
var width = 0;
2732
var height = 0;
33+
2834
for (var i = 0; i < json.layer.length; i++)
2935
{
3036
if (json.layer[i].width > width) { width = json.layer[i].width; }

src/tilemaps/parsers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
Parse2DArray: require('./Parse2DArray'),
99
ParseCSV: require('./ParseCSV'),
1010

11-
Impact: require('./impact'),
12-
Tiled: require('./tiled')
11+
Impact: require('./impact/ParseWeltmeister'),
12+
Tiled: require('./tiled/ParseJSONTiled')
1313

1414
};

src/tilemaps/parsers/tiled/AssignTileProperties.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
var Extend = require('../../../utils/object/Extend');
22

3-
// Copy properties from tileset to tiles
3+
/**
4+
* Copy properties from tileset to tiles.
5+
*
6+
* @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties
7+
* @since 3.0.0
8+
*
9+
* @param {Phaser.Tilemaps.MapData} mapData - [description]
10+
*/
411
var AssignTileProperties = function (mapData)
512
{
613
var layerData;

src/tilemaps/parsers/tiled/Base64Decode.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* [description]
3+
*
4+
* @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode
5+
* @since 3.0.0
6+
*
7+
* @param {object} data - [description]
8+
*
9+
* @return {array} [description]
10+
*/
111
var Base64Decode = function (data)
212
{
313
var binaryString = window.atob(data);

src/tilemaps/parsers/tiled/BuildTilesetIndex.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
// Master list of tiles -> x, y, index in tileset
1+
/**
2+
* Master list of tiles -> x, y, index in tileset.
3+
*
4+
* @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex
5+
* @since 3.0.0
6+
*
7+
* @param {Phaser.Tilemaps.MapData} mapData - [description]
8+
*
9+
* @return {array} [description]
10+
*/
211
var BuildTilesetIndex = function (mapData)
312
{
413
var tiles = [];

0 commit comments

Comments
 (0)