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.

This commit is contained in:
photonstorm 2014-04-28 13:47:27 +01:00
parent 348e3c14bd
commit e9436293a8
2 changed files with 13 additions and 0 deletions

View file

@ -81,6 +81,7 @@ Version 2.0.4 - "Mos Shirare" - in development
* Input and Pointer now use the new ArrayList instead of a LinkedList, which resolve list item removable during callback issues. * Input and Pointer now use the new ArrayList instead of a LinkedList, which resolve list item removable during callback issues.
* 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. * 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.
* 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. * 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.
* 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.
### New Features ### New Features

View file

@ -246,6 +246,12 @@ Phaser.Tilemap.prototype = {
if (typeof tileset === 'string') if (typeof tileset === 'string')
{ {
key = tileset; key = tileset;
if (!this.game.cache.checkImageKey(key))
{
console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "' + key + '"');
return null;
}
} }
else else
{ {
@ -256,6 +262,12 @@ Phaser.Tilemap.prototype = {
if (typeof tileset === 'string') if (typeof tileset === 'string')
{ {
tileset = this.getTilesetIndex(tileset); tileset = this.getTilesetIndex(tileset);
if (tileset === null)
{
console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "' + key + '"');
return null;
}
} }
if (this.tilesets[tileset]) if (this.tilesets[tileset])