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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.