Skip to content

Commit 3f08689

Browse files
committed
Tilemap parsers: remove width & height parameters since they are inferred
1 parent bf19553 commit 3f08689

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

v3/src/gameobjects/tilemap/Parse.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
var Formats = require('./Formats');
22
var Parsers = require('./parsers');
33

4-
var Parse = function (key, mapFormat, mapData, tileWidth, tileHeight, width, height, insertNull)
4+
var Parse = function (key, mapFormat, mapData, tileWidth, tileHeight, insertNull)
55
{
66
var newMap;
77

88
switch(mapFormat)
99
{
1010
case (Formats.TILEMAP_2D_ARRAY):
11-
newMap = Parsers.Parse2DArray(key, mapData, tileWidth, tileHeight, width, height, insertNull);
11+
newMap = Parsers.Parse2DArray(key, mapData, tileWidth, tileHeight, insertNull);
1212
break;
1313
case (Formats.TILEMAP_CSV):
14-
newMap = Parsers.ParseCSV(key, mapData, tileWidth, tileHeight, width, height, insertNull);
14+
newMap = Parsers.ParseCSV(key, mapData, tileWidth, tileHeight, insertNull);
1515
break;
1616
case (Formats.TILEMAP_TILED_JSON):
1717
newMap = Parsers.ParseTiledJSON(key, mapData, insertNull);

v3/src/gameobjects/tilemap/TilemapCreator.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ GameObjectCreator.register('tilemap', function (config)
1414
// tileHeight: 32,
1515
// width: 10,
1616
// height: 10,
17-
// data: null (2D array of tile indices)
17+
// data: null (2D array of tile indices),
18+
// insertNull: false
1819
// }
1920

2021
var key = GetFastValue(config, 'key', null);
2122
var tileWidth = GetFastValue(config, 'tileWidth', 32);
2223
var tileHeight = GetFastValue(config, 'tileHeight', 32);
2324
var width = GetFastValue(config, 'width', 10);
2425
var height = GetFastValue(config, 'height', 10);
26+
var insertNull = GetFastValue(config, 'insertNull', false);
2527
var data = GetFastValue(config, 'data', null);
2628

2729
var parsedData = null;
2830
if (key === null && Array.isArray(data))
2931
{
30-
parsedData = Parse(key, Formats.TILEMAP_2D_ARRAY, data, tileWidth, tileHeight, width, height);
32+
parsedData = Parse(key, Formats.TILEMAP_2D_ARRAY, data, tileWidth, tileHeight, insertNull);
3133
}
3234
else if (key !== null)
3335
{
@@ -39,7 +41,7 @@ GameObjectCreator.register('tilemap', function (config)
3941
}
4042
else
4143
{
42-
parsedData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, width, height);
44+
parsedData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull);
4345
}
4446
}
4547

v3/src/gameobjects/tilemap/TilemapFactory.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@ GameObjectFactory.register('tilemap', function (config)
2121
// tileHeight: 32,
2222
// width: 10,
2323
// height: 10,
24-
// data: null (2D array of tile indices)
24+
// data: null (2D array of tile indices),
25+
// insertNull: false
2526
// }
2627

2728
var key = GetFastValue(config, 'key', null);
2829
var tileWidth = GetFastValue(config, 'tileWidth', 32);
2930
var tileHeight = GetFastValue(config, 'tileHeight', 32);
3031
var width = GetFastValue(config, 'width', 10);
3132
var height = GetFastValue(config, 'height', 10);
33+
var insertNull = GetFastValue(config, 'insertNull', false);
3234
var data = GetFastValue(config, 'data', null);
3335

3436
var parsedData = null;
3537
if (key === null && Array.isArray(data))
3638
{
37-
parsedData = Parse(key, Formats.TILEMAP_2D_ARRAY, data, tileWidth, tileHeight, width, height);
39+
parsedData = Parse(key, Formats.TILEMAP_2D_ARRAY, data, tileWidth, tileHeight, insertNull);
3840
}
3941
else if (key !== null)
4042
{
@@ -46,7 +48,7 @@ GameObjectFactory.register('tilemap', function (config)
4648
}
4749
else
4850
{
49-
parsedData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, width, height);
51+
parsedData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull);
5052
}
5153
}
5254

0 commit comments

Comments
 (0)