xompl Posted September 29, 2014 Share Posted September 29, 2014 Hi, I was trying to minimize the total loading time so I wanted to load some assets such as the credits music in background during the game. What I did is to add the assets to the queue during of the main meni create() instead of during the preload state. I had to start the loader myself. this.game.load.audio('music_credits', ['assets/music_credits.mp3', 'assets/music_credits.ogg']); this.load.start(); This totally works, it loads the music in parallel with the main menu execution and later I can play it in the credits state but I get the followingconsole errors when I execute the start(): Chrome:Uncaught TypeError: Cannot read property 'x' of null Firefox:TypeError: this._frame is null Am I doing it wrong? Any sugestion? Thanks! Link to comment Share on other sites More sharing options...
rich Posted September 29, 2014 Share Posted September 29, 2014 Did you previously use a preloadSprite? If so I think it might be this - set preloadSprite to be nothing and I think it may go away. Link to comment Share on other sites More sharing options...
xompl Posted September 29, 2014 Author Share Posted September 29, 2014 Thank you! The error went away with this.load.preloadSprite = null; I still need to study the performance implications of loading in background... Thanks Link to comment Share on other sites More sharing options...
rich Posted September 29, 2014 Share Posted September 29, 2014 Loading itself should be ok, but if the audio file needs decoding (for example mp3s do) then it will hammer the CPU while it does that, freezing up everything else. Link to comment Share on other sites More sharing options...
xompl Posted September 29, 2014 Author Share Posted September 29, 2014 Hi rich, At least on Linux with both Chrome and Firefox I don't notice any slowdown, maybe it has its own decoding thread. but I haven't tested on mobile devices yet. Link to comment Share on other sites More sharing options...
Wavertron Posted October 4, 2014 Share Posted October 4, 2014 This sounds pretty neat. My game is a little slow to load, might try this out. Link to comment Share on other sites More sharing options...
Recommended Posts