Jump to content

Tiled JSON parser attempts to locate a non-existent tile 'gid'


Matt F
 Share

Recommended Posts

Hi!

 

This may very well be due to my own inexperience with Tiled, but I'm faced with an error, and I'm not sure how to proceed.

 

The code:

this.load.tilemap("level1-map", "img/level1.json", null, Phaser.Tilemap.TILED_JSON);...map = this.add.tilemap("level1-map"); 

The error:

Uncaught TypeError: Cannot read property '2' of undefined

In terms of the tilemap itself, I have a tile layer and an object layer, and 4 tilesets composed of individual images. That's all. Nothing rotated/flipped, either.

 

Through debugging I found that this error is thrown while my tile layer is being parsed. The encoded layer data is "eJxjYWBgYKEyphYYNW\/UvFHzhr551MQAcZ4BCQ==". The error is being thrown when the parser attempts to locate a tile of index/gid '5', when my tiles only go up to 4.

 

Am I missing a step here? As far as I can tell, I'm following all of the examples I've seen.

 

Thanks!

Link to comment
Share on other sites

@Skeptron as far as I can tell it matches the example field-wise, though mine has an object layer and the data is encoded/compressed. Here's the file: https://github.com/mfugere/tether2/blob/dev/img/level1.json

 

@jmp909 I'm a bit shaky with the CSV implementation, but it looks like my object layer isn't making it into the final CSV. I can clearly see only 2 values in the file (-1 and 0). The tile layer shows up, and everything else functions as it should.

Link to comment
Share on other sites

set Tiled map format to CSV under Map->Map Properties (or XML, it won't matter) and then export as json & the game then works fine

 

i've just downloaded your source and tried it. phaser doesn't support the compression

 

(by the way if i press right, then up as well afterwards, it doesn't go diagonally.. but if i press up and then right afterwards it does)

Link to comment
Share on other sites

@jmp909 brilliant! As usual I didn't read the fine print of "This update adds in automatic support for this as long as the data isn't compressed" in the release notes. To that point, the uncompressed base64 format works as well.

 

Thanks a lot. As for the player, I plan on preventing diagonal movement. Too lazy to animate.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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