cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Q.load callback not called if no assets are loaded. #110

Closed brofist56489 closed 10 years ago

brofist56489 commented 10 years ago

I tried to make a simple test with Quintus. However, I tried the following:

//Quintus stuff already setup.

Q.load([], function() { Q.gameLoop(function(dt) { Q.ctx.fillStyle = "#0000ff"; Q.ctx.fillRect(0, 0, 100, 100); }); });

The problem being that the callback function for Q.load was never called. After about an hour of stepping through the code in debug mode, I found that the method isn't called if it doesn't have to load anything.

So I added the following after the loadedCallback function definition:

if(assetsRemaining === 0) { callback.apply(Q); }

This fixed the problem for me. You might be able to come up with a better solution.

ghost commented 10 years ago

If there's nothing to load why would you use Q.load()? might well just call the function normally. This seems to be a good solution though, but i don't think there is a problem at all. If you think this is critical for any reason, make a pull request with a detailed explanation, and if it's good enough we'll merge your changes. Thanks.