Pau

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

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

Share this post


Link to post
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');

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.