neon Posted August 2, 2014 Share Posted August 2, 2014 Hi all, I have a little problem. I get sometimes the error "Phaser.Loader fileComplete invalid index 0" but after pressing f5 it goes away, or sometimes i need reload several times. I see this error since I updated to some 2.0.x version (currently I have 2.0.5), 1.x versions were fine. I can't post the complete source, because its a lot but in general it's a quite simple setup: gameObject.load.image(...);gameObject.load.image(...);...gameObject.load.onLoadComplete.addOnce(callback, this);gameObject.load.start(); If I step everything in debugger, then I never get the error. What can be a possible problem and why does the debugger mode solve it? Thanks a lot! Link to comment Share on other sites More sharing options...
neon Posted August 3, 2014 Author Share Posted August 3, 2014 Ok found the bug, somehow if i had the image path as "/images/fubar.png" i got the error sometimes and now with "../../images/fubar.png" not anymore. I don't know if it's Phaser error or the error in my backend, but at least I got this fixed now had the issue for weeks Edit:Was too quick. Still have the bug. For some reasons the "_fileList" in the loader is sometimes empty and sometimes not. The error message is from the "fileComplete". Its strange because the comment for the function is " Called when a file is successfully loaded.", so the file should be actually loaded Edit2: Ok, I probably found the problem. In Phaser source, before the file is loaded and fileComplete is called, somehow the reset function gets called (I load my files not in the init function or so) and reset is triggered by preUpdate StateManager function. There I find:if (this.onPreloadCallback){ this.game.load.reset(); this.onPreloadCallback.call(this.callbackContext, this.game); // Is the loader empty? if (this.game.load.totalQueuedFiles() === 0) { this.loadComplete(); } else { // Start the loader going as we have something in the queue this.game.load.start(); }}So game.load.reset is called and in the next the check "if (this.game.load.totalQueuedFiles() === 0)" is made, but doesn't load.reset() resets the file queue so its always true? I changed it to:if (this.onPreloadCallback){ this.onPreloadCallback.call(this.callbackContext, this.game); // Is the loader empty? if (this.game.load.totalQueuedFiles() === 0) { this.loadComplete(); this.game.load.reset(); } else { // Start the loader going as we have something in the queue this.game.load.start(); }}And its seems to work, I don't get the "Phaser.Loader fileComplete invalid index 0" after 10 tries. But it's random, so maybe it's still not solved and I missed something. But I haven't looked deep in the code and still use the older 2.0.5 version (because 2.0.7 has some position issues for my saved games). Link to comment Share on other sites More sharing options...
Manifest Posted August 4, 2014 Share Posted August 4, 2014 So are you attaching a callback to the loader and trying to progress manually once the loader is complete? I don't know if you're operating within a Phaser.State but I believe that if you start loading something in the preload of a state, the next 'step' (create()) is called automatically when the loading is done -- you don't need to add a callback yourself. Link to comment Share on other sites More sharing options...
Recommended Posts