Jump to content

Game freezing: Map won't load, error is unclear


friedmr5
 Share

Recommended Posts

Hi all,

I'm new to development in general and definitely new to Phaser, and I have run into an issue I haven't seen mentioned elsewhere.  I had followed a tutorial from Discover Phaser to create my first game. The tilemap was created using Tiled and exported as a JSON file. In order to get the tutorial game to run, I needed to edit the data in the JSON file. I'm using Brackets to edit my code and have not touched the minified framework file.

I am now building my own simple game with a small tilemap (12x12), and have exported a JSON file. However, whether I leave the JSON file as is, or I edit it so that its structure is identical to what worked in Discover Phaser's tutorial, my game still crashes when it tries to load the map. The errors I get look like this: 

Quote

Uncaught TypeError: Cannot read property '2' of undefined
    at Object.parseTiledJSON (phaser.min.js:26)
    at Object.parse (phaser.min.js:26)
    at new c.Tilemap (phaser.min.js:25)
    at c.GameObjectFactory.tilemap (phaser.min.js:15)
    at Object.createWorld (play.js:289)
    at Object.create (play.js:25)
    at c.StateManager.loadComplete (phaser.min.js:10)
    at c.StateManager.preUpdate (phaser.min.js:10)
    at c.Game.updateLogic (phaser.min.js:12)
    at c.Game.update (phaser.min.js:12)

When I try exporting the map as a CSV file, the game no longer freezes, but the map still doesn't load. The only error that shows is this one, from the 25th line of the phaser.min.js file:

Quote

Tilemap.createLayer: Invalid layer ID given: null

There are a few things I don't know. 

  • What any of these errors mean in terms of trying to load the tilemap
  • Why I'm getting these errors
  • What Phaser is expecting to come out of these files. What is it reading? 

If anyone could shed some light on this, I'd be eternally grateful. 

Link to comment
Share on other sites

The first error means Phaser failed to read/interpret the exported map. That step should succeed for a typical map exported from Tiled, so the most likely cause is that editing the map file by hand spoiled it.

The second error means Phaser couldn't find the layer named in the createLayer call. 

Link to comment
Share on other sites

Hi Samme, 

Thank you for your reply. I agree, editing the map by hand probably did spoil it. Tiled wouldn't even reopen the JSON files that I touched. What I don't understand is why these errors don't go away when I leave the file in its default state. 

I will make sure to double check all of my layer names, etc, as Skeptron has suggested.

Will update this thread when I go back and test it again.

Link to comment
Share on other sites

On 2017/6/17 at 2:18 AM, fpg246 said:

Hi Samme, 

Thank you for your reply. I agree, editing the map by hand probably did spoil it. Tiled wouldn't even reopen the JSON files that I touched. What I don't understand is why these errors don't go away when I leave the file in its default state. 

I will make sure to double check all of my layer names, etc, as Skeptron has suggested.

Will update this thread when I go back and test it again.

hi,fpg246

you need use this old ver 0.18.2

down link : https://github.com/bjorn/tiled/releases/tag/v0.18.2

today I updated TiledMap to ver-1.0.1,export json file,the errors has show.

so I decided to use old ver,and then the code run ok.

tip:just export JSON,not CSV

hope can help you ?

Edited by nimohe
add tip
Link to comment
Share on other sites

10 hours ago, samme said:

So the problem is the new external tileset (.tsx) feature in Tiled v1.0.0.

You need to use either the Import Tileset button or Map → Add External Tileset, I'm not sure which.

solved !!!

I updated my github :https://github.com/nimohe/test-Tiledmapeditor-export-JSON-with-Phaser

 

solved way:embed.png.a454c28d3369b42c69ed55432f8d5a55.png

 need to click 'Embed Tileset' button -->then export JSON --> run code will be ok

Link to comment
Share on other sites

On 6/21/2017 at 0:48 PM, samme said:

So the problem is the new external tileset (.tsx) feature in Tiled v1.0.0.

You need to use either the Import Tileset button or Map → Add External Tileset, I'm not sure which.

This was it!!! Thank you so much!

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

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