Jump to content

Error: No data found in the JSON tilemap from Tiled matching the tileset name: "gameTiles"


Pau
 Share

Recommended Posts

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

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');
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...