SuperMarco Posted October 1, 2014 Share Posted October 1, 2014 Hi, I just started to use Tiled Map Editor (to create my debug map for now to develop all of the feature of my game), but every time I use it it show the wrong id inside my json file. Example : As you can see here I have 4 images (don't pay attention to the cut one on the right, its just to explain my problem), so the id should be 0, 1, 2, 3. When I use Tiled and export it : instead of 0 it's 1 and instead of 1 its 2 etc.. I have read that is because for tiled, the 0 correspond to a "no tile", but I don't know how I can fix this.. Most likely my code looks like this :preload: function() { this.game.load.tilemap('mainLand', 'assets/mainLand.json', null, Phaser.Tilemap.TILED_JSON); this.game.load.image('tileset', 'assets/grassland.png'); }, create: function() { this.ground = this.game.add.tilemap('mainLand'); this.ground.addTilesetImage('tileset'); this.layer = this.ground.createLayer('Main land'); this.layerDetail = this.ground.createLayer('Detail'); this.layer.resizeWorld(); },Can someone help me to fix this ? Thanks ! Link to comment Share on other sites More sharing options...
j0hnskot Posted October 1, 2014 Share Posted October 1, 2014 Can we see the json file?I remember tiled reporting different ids from what i expected because it used a white block as a different image (let's say that there are 3 images , tiled created a white block so the images would then be 4). Link to comment Share on other sites More sharing options...
SuperMarco Posted October 1, 2014 Author Share Posted October 1, 2014 Of course here you go : http://pastebin.com/jnQSsgH3 Link to comment Share on other sites More sharing options...
SuperMarco Posted October 1, 2014 Author Share Posted October 1, 2014 I remember tiled reporting different ids from what i expected because it used a white block as a different image (let's say that there are 3 images , tiled created a white block so the images would then be 4). I tried to cheat a bit letting a blank area at the beginning, but its still not really working.. or working ish. Is there is a way to use options somewhere in the code to change that ? or I have to edit the json file by hand? ^^' Link to comment Share on other sites More sharing options...
j0hnskot Posted October 1, 2014 Share Posted October 1, 2014 The problem the different ids create is that it messes up the look of the level (for example the screen is different than it is on Tiled) ?I looked at a map i created in the past and indeed zero represents 'no tile'. But the look was as expected. Link to comment Share on other sites More sharing options...
SuperMarco Posted October 1, 2014 Author Share Posted October 1, 2014 For example my map looks like this : So yeah, it messes up a lot. I don't know what to do really I just found this on git : https://github.com/bjorn/tiled/issues/605 but I don't understand what is the solution.. Link to comment Share on other sites More sharing options...
nak3ddogs Posted October 2, 2014 Share Posted October 2, 2014 Hi. I had this problem too but im not at pc and i cant check the json. The tilemap png name is same what have u used when build your map in tiled editor? Coz is it possible u need one more argument in add tile set image. Check the example. Im sure the tilsetimage is bad. But im newby. Link to comment Share on other sites More sharing options...
SuperMarco Posted October 2, 2014 Author Share Posted October 2, 2014 I looked at the doc and it says this : addTilesetImage(tileset, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) from http://docs.phaser.io/Phaser.Tilemap.html I have check the examples but I couldn't find anything about an other argument passed except the tileset. Link to comment Share on other sites More sharing options...
j0hnskot Posted October 2, 2014 Share Posted October 2, 2014 According to the docs the tileset must be added like this : this.ground.addTilesetImage('Grassland' , 'tileset');Grassland being the name you used in the TIled for your tileset. SuperMarco 1 Link to comment Share on other sites More sharing options...
SuperMarco Posted October 2, 2014 Author Share Posted October 2, 2014 Damned... I feel like an idiot.. it's working fine now thanks you ! Link to comment Share on other sites More sharing options...
Recommended Posts