Jump to content

Preloading with promises or callbacks?


jmeyers919
 Share

Recommended Posts

Is there any way to interact with the Phaser loader using promises or callbacks? From what I can tell, Phaser manages all of the async aspects of preloading internally. Are there any methods that would allow me to run my own async process during the preload and notify Phaser when my process has completed? Something like this:

this.load.fromCallback(function(callback) {  setTimeout(function() {    callback();  }, 1000);});

or

this.load.fromPromise(myPromise);
Link to comment
Share on other sites

Let's say you have a "preload" state. Phaser will run the preload method on your preload state to load everything. Then it will call the create method. Normally, you'd switch to a new state (main menu or game or something). Instead, you run all your promises in the "create" method and make the finally (or the final then) switch states. You should be good.

 

EDIT: Er, what Michael said. ( =

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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