Jump to content

Load JSON on init() then get it on preload(), it's possible?


Arthur Miksza
 Share

Recommended Posts

Hi!
I need load some images based on a JSON, I've tried:

init() {
   game.load.json('json_key', 'url_to_json.json');
   game.load.start();
}

and then:

preload() {
   game.cache.getJSON('json_key').imagesName.forEach((name) => {
      game.load.image(name, 'url' + name + '.png');
   });
}

but it's not working...
the variable game.cache.getJSON('json_key') is null on preload(), but it has the value on create();

I don't wanna use onLoadComplete() because the generic loading bar that I'm using won't calculate the values after the load has completed.
Edit: I know it's possible on create(), but I need it on preload for the loading bar


So that's my question, is there any way to do it?

Thanks;

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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