@@ -319,7 +319,7 @@ var Tilemap = new Class({
319319
320320 if ( ! this . scene . sys . textures . exists ( key ) )
321321 {
322- console . warn ( 'Invalid image key given for tileset: " ' + key + '"' ) ;
322+ console . warn ( 'Invalid Tileset Image: ' + key ) ;
323323 return null ;
324324 }
325325
@@ -329,16 +329,19 @@ var Tilemap = new Class({
329329
330330 if ( index === null && this . format === Formats . TILED_JSON )
331331 {
332- console . warn ( 'No data found in the JSON tilemap from Tiled matching the tileset name: " ' + tilesetName + '"' ) ;
332+ console . warn ( 'No data found for Tileset: ' + tilesetName ) ;
333333 return null ;
334334 }
335335
336- if ( this . tilesets [ index ] )
336+ var tileset = this . tilesets [ index ] ;
337+
338+ if ( tileset )
337339 {
338- this . tilesets [ index ] . setTileSize ( tileWidth , tileHeight ) ;
339- this . tilesets [ index ] . setSpacing ( tileMargin , tileSpacing ) ;
340- this . tilesets [ index ] . setImage ( texture ) ;
341- return this . tilesets [ index ] ;
340+ tileset . setTileSize ( tileWidth , tileHeight ) ;
341+ tileset . setSpacing ( tileMargin , tileSpacing ) ;
342+ tileset . setImage ( texture ) ;
343+
344+ return tileset ;
342345 }
343346
344347 if ( tileWidth === undefined ) { tileWidth = this . tileWidth ; }
@@ -347,8 +350,10 @@ var Tilemap = new Class({
347350 if ( tileSpacing === undefined ) { tileSpacing = 0 ; }
348351 if ( gid === undefined ) { gid = 0 ; }
349352
350- var tileset = new Tileset ( tilesetName , gid , tileWidth , tileHeight , tileMargin , tileSpacing ) ;
353+ tileset = new Tileset ( tilesetName , gid , tileWidth , tileHeight , tileMargin , tileSpacing ) ;
354+
351355 tileset . setImage ( texture ) ;
356+
352357 this . tilesets . push ( tileset ) ;
353358
354359 return tileset ;
@@ -729,30 +734,33 @@ var Tilemap = new Class({
729734
730735 if ( index === null )
731736 {
732- console . warn ( 'Cannot create tilemap layer, invalid layer ID given : ' + layerID ) ;
737+ console . warn ( 'Invalid Tilemap Layer ID : ' + layerID ) ;
733738 return null ;
734739 }
735740
736741 var layerData = this . layers [ index ] ;
737742
738- // Check for an associated static or dynamic tilemap layer
743+ // Check for an associated static or dynamic tilemap layer
739744 if ( layerData . tilemapLayer )
740745 {
741- console . warn ( 'Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID :' + layerID ) ;
746+ console . warn ( 'Tilemap Layer ID already exists:' + layerID ) ;
742747 return null ;
743748 }
744749
745750 this . currentLayerIndex = index ;
746751
747- // Make sure that all the LayerData & the tiles have the correct tile size. They usually
752+ // Make sure that all the LayerData and the tiles have the correct tile size. They usually
748753 // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made
749754 // with a 1x res tileset.
755+
756+ /*
750757 if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight)
751758 {
752759 this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index);
753760 }
761+ */
754762
755- // Default the x/y position to match Tiled layer offset, if it exists.
763+ // Default the x/y position to match Tiled layer offset, if it exists.
756764 if ( x === undefined && this . layers [ index ] . x ) { x = this . layers [ index ] . x ; }
757765 if ( y === undefined && this . layers [ index ] . y ) { y = this . layers [ index ] . y ; }
758766
0 commit comments