MapData and ObjectLayer will now enforce that the Tilemap.objects property is always an array. Sometimes Tiled willl set it to be a blank object in the JSON data. This fix makes sure it is always an array. Fix #6139

This commit is contained in:
Richard Davey 2022-11-17 14:28:23 +00:00
parent eec8b6a507
commit 759599e4d1
2 changed files with 13 additions and 1 deletions

View file

@ -178,8 +178,14 @@ var MapData = new Class({
*/
this.objects = GetFastValue(config, 'objects', []);
// Because Tiled can sometimes create an empty object if you don't populate it, not an empty array
if (!Array.isArray(this.objects))
{
this.objects = [];
}
/**
* An object of collision data. Must be created as physics object or will return undefined.
* An object of collision data. Must be created as physics object or will return undefined.
*
* @name Phaser.Tilemaps.MapData#collision
* @type {object}

View file

@ -109,6 +109,12 @@ var ObjectLayer = new Class({
* @since 3.0.0
*/
this.objects = GetFastValue(config, 'objects', []);
// Because Tiled can sometimes create an empty object if you don't populate it, not an empty array
if (!Array.isArray(this.objects))
{
this.objects = [];
}
}
});