jmeyers919 Posted September 21, 2015 Share Posted September 21, 2015 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);});orthis.load.fromPromise(myPromise); Link to comment Share on other sites More sharing options...
MichaelD Posted September 22, 2015 Share Posted September 22, 2015 You could load the assets using defered calls (promises) and then pass the key:values to the game cache and simply change state. jmeyers919 1 Link to comment Share on other sites More sharing options...
drhayes Posted September 22, 2015 Share Posted September 22, 2015 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. ( = jmeyers919 and MichaelD 2 Link to comment Share on other sites More sharing options...
Recommended Posts