Skip to content

Commit e943629

Browse files
committed
Tilemap.addTilesetImage will now raise a console.warn if you specify an invalid tileset key and not create the tileset rather than pick the default set.
1 parent 348e3c1 commit e943629

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Version 2.0.4 - "Mos Shirare" - in development
8181
* Input and Pointer now use the new ArrayList instead of a LinkedList, which resolve list item removable during callback issues.
8282
* Input.reset no longer resets every interactive item it knows of, because they are removed during the destroy phase and can now persist between States if needed.
8383
* Blank Tilemaps no longer create `null` tiles, but instead create Tile objects with an index of -1 which can be replaced and updated like any other tile.
84+
* Tilemap.addTilesetImage will now raise a console.warn if you specify an invalid tileset key and not create the tileset rather than pick the default set.
8485

8586

8687
### New Features

src/tilemap/Tilemap.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ Phaser.Tilemap.prototype = {
246246
if (typeof tileset === 'string')
247247
{
248248
key = tileset;
249+
250+
if (!this.game.cache.checkImageKey(key))
251+
{
252+
console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + key + '"');
253+
return null;
254+
}
249255
}
250256
else
251257
{
@@ -256,6 +262,12 @@ Phaser.Tilemap.prototype = {
256262
if (typeof tileset === 'string')
257263
{
258264
tileset = this.getTilesetIndex(tileset);
265+
266+
if (tileset === null)
267+
{
268+
console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "' + key + '"');
269+
return null;
270+
}
259271
}
260272

261273
if (this.tilesets[tileset])

0 commit comments

Comments
 (0)