clark Posted June 19, 2014 Share Posted June 19, 2014 You may be familiar with this:preload(){ this.load.image("preloadbg", urlToPreloadBG); this.load.image("preloadbgbar", urlToPreloadBGBar);}But I wondered, how would you handle a situation where the game depends on JSON in order to further load data? So for example preload(){ var that = this; this.load.onLoadComplete.addOnce( function(){ //great, I have config, and I parsed it, and now I need to load a language file and do not want to start just yet that.load.onLoadComplete.addOnce(function(){ console.log("TADA, now continue"); }); that.load.json("en", urlToEn); }); this.load.image("preloadbg", urlToPreloadBG); this.load.image("preloadbgbar", urlToPreloadBGBar); this.load.json("config", urlToConfig);}I messed around with the reset() and also tried onFileComplete and so on but not having much luck after the initial preloadbg/preloadbgbar/config is loaded. Link to comment Share on other sites More sharing options...
lewster32 Posted June 19, 2014 Share Posted June 19, 2014 Create a state which preloads your required data assets first, and then when they're loaded, progress to the next state which preloads the assets dependent on these initial data assets. See the basic template for a simple example of setting up states. clark 1 Link to comment Share on other sites More sharing options...
clark Posted June 19, 2014 Author Share Posted June 19, 2014 Thanks mate lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts