Matt F Posted November 10, 2015 Share Posted November 10, 2015 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 undefinedIn 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 More sharing options...
Skeptron Posted November 10, 2015 Share Posted November 10, 2015 Could you show us your JSON? Did you try to compare with a valid JSON such as the ones from the example? Mario example : http://examples.phaser.io/assets/tilemaps/maps/super_mario.json Link to comment Share on other sites More sharing options...
jmp909 Posted November 10, 2015 Share Posted November 10, 2015 do you get the same error when outputting the json file from Tiled as CSV format? Link to comment Share on other sites More sharing options...
Matt F Posted November 10, 2015 Author Share Posted November 10, 2015 @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 More sharing options...
jmp909 Posted November 11, 2015 Share Posted November 11, 2015 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) drhayes 1 Link to comment Share on other sites More sharing options...
Matt F Posted November 11, 2015 Author Share Posted November 11, 2015 @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 More sharing options...
Recommended Posts