Pau Posted July 19, 2018 Share Posted July 19, 2018 Hello, I am trying to load a tilemap mad with tiled, but i am getting this error in the console: Error: No data found in the JSON tilemap from Tiled matching the tileset name: "gameTiles" This is the code i am using in phaser: function preload(){ this.load.tilemapTiledJSON('level1', 'map.json'); this.load.image('gameTiles', 'tiles.png'); //this.load.spritesheet('gameTiles', '../img/tiles.png', { frameWidth: 32, frameHeight: 32 }); } function create(){ map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('gameTiles'); backgroundLayer = map.createStaticLayer('background', tileset,0,0); } I give you the complete source code in the attachment. It is not so much. Thanks in advance. 1-carga-carretera.zip Link to comment Share on other sites More sharing options...
NoxBrutalis Posted July 19, 2018 Share Posted July 19, 2018 When you set tilesetImage(gametiles) you're using the key you gave the texture in game code. there should be an argument before that, and that's the name you gave the tileset image in tiled itself. So, in my game, the key I gave the image was tiles, but in tiled for some reason I called it tilesheet. So I had to do this this.tiles = this.map.addTilesetImage('tileSheet1', 'tiles'); if you called it gameTiles in tiled also, then: this.tiles = this.map.addTilesetImage('gameTiles', 'gameTiles'); CharlieCalvert and LiadIdan 1 1 Link to comment Share on other sites More sharing options...
Pau Posted July 19, 2018 Author Share Posted July 19, 2018 Thank you! your explanation solved my problem. I share my on code-explanation. function preload(){ this.load.tilemapTiledJSON('level1', 'map.json'); this.load.image('tilesetNameInPhaser', 'tiles.png'); } function create(){ map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('tilesetNameInTiled', 'tilesetNameInPhaser'); backgroundLayer = map.createStaticLayer('background', tileset,0,0); } Thank you! NoxBrutalis 1 Link to comment Share on other sites More sharing options...
Recommended Posts