Jump to content

Phaser fails to parse tilemap json?


oxysoft
 Share

Recommended Posts

I thought it could have been my tiled json that was improper or whatever but I tried using the Desert.json along with the tileset from the phaser examples and it's the same result

 

Picture:

uuOqDbK.png

 

This is the code used to create the map and the ground layer

var map = this.game.add.tilemap('desert');map.addTilesetImage('desert', 'tiles');var layer = map.createLayer(0);

Note that

createLayer('Ground')

has no effect and yields the following error message in the console

Tilemap.createLayer: Invalid layer ID given: null

So I logged to the console the name of the layer which is supposed to be Ground according to the json file and phaser examples and it came up as layer for some reasons

Furthermore, the width of the map is always equal to 2 despite being set to 40 in the json file.

Logging to the console more properties from the map seems to reveal that they are all set to default values.

 

So is it failing to read the json or what?

 

This is the statement used to load it in the preload function

this.game.load.tilemap('desert', 'assets/desert.json', null, Phaser.TILEMAP.TILED_JSON);

Thanks

Link to comment
Share on other sites

Kinda weird how I noticed immediately after posting

 

This is a little off topic of the original post, but not it isn't, and here's why.  When you make a detailed forum post it causes you to think critically about things you might not have thought about before.  In my day to day programming I've come to practice a programming methodology which I've dubbed "StackOverflow Programming."  When I have a problem that I just can't solve, I start writing up a post for SO or whatever forum can help me.  I'm sure to be as detailed as I can to be sure that whoever will be reading it won't need any more information from me.  This ensures that I've seen as many of the facts as I can.  Then I check and double check that what I'm writing down is true to the situation.  If, by the time I consider the post finished, I have not figured out the problem, I hit that submit button.  But let me tell you, I only submit about 10% of the forum posts I start, and half of those are answered by me within an hour.  This isn't an entirely unusual idea either.  You get the same benefits from talking your problem over with another person (knowledgable programmer or not), or even... a teddy bear (http://blog.adrianbolboaca.ro/2012/12/teddy-bear-pair-programming/)

Link to comment
Share on other sites

This is a little off topic of the original post, but not it isn't, and here's why.  When you make a detailed forum post it causes you to think critically about things you might not have thought about before.  In my day to day programming I've come to practice a programming methodology which I've dubbed "StackOverflow Programming."  When I have a problem that I just can't solve, I start writing up a post for SO or whatever forum can help me.  I'm sure to be as detailed as I can to be sure that whoever will be reading it won't need any more information from me.  This ensures that I've seen as many of the facts as I can.  Then I check and double check that what I'm writing down is true to the situation.  If, by the time I consider the post finished, I have not figured out the problem, I hit that submit button.  But let me tell you, I only submit about 10% of the forum posts I start, and half of those are answered by me within an hour.  This isn't an entirely unusual idea either.  You get the same benefits from talking your problem over with another person (knowledgable programmer or not), or even... a teddy bear (http://blog.adrianbolboaca.ro/2012/12/teddy-bear-pair-programming/)

 

Haha yeah, that is indeed very true. I think the teddy bear pair programming is more popular under the name of rubber duck debugging!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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