Jump to content

How can I load JSON and then use it?


Vaughan
 Share

Recommended Posts

I see that there's a jsonLoadComplete callback but it returns an index and there's no real documentation or examples on how to do this. For example, I have a JSON with all the sprites I want to load up front -- how can I load this JSON, and then proceed to iterate that object to load the rest? 

Link to comment
Share on other sites

One way is to use multiple states for your preloading.  In your first state's preload function,  load the JSON and any other assets you already know you need.  Then in the next state's preload function, read the json and load the textures. Then in create function of that state you are all set to render.

 

http://docs.phaser.io/Phaser.StateManager.html

Link to comment
Share on other sites

Isn't the loader inactive then? I need to load textures based on this JSON file. I was under the impression when preload ends that phasers loader becomes inactive. 

I would assume that the callback you add to onLoadComplete would get called once the load process completes, so if you add the callback in the preload function then it will get called.

 

Edit: I see missed your point. Go with sleekdigital's suggestion.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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