cocos2d / cocos2d-html5

Cocos2d for Web Browsers. Built using JavaScript.
https://www.cocos.com
3.06k stars 904 forks source link

_prepared is never set to true when js-files are minimized (project.json does not contain a jsList) #3536

Open hamburml opened 6 years ago

hamburml commented 6 years ago

_prepared is set to false when created (https://github.com/cocos2d/cocos2d-html5/blob/develop/CCBoot.js#L2365)

_prepared is set to true when the project.json file has a jsList which is loaded AFTER the cocos2d-html5 files were loaded (https://github.com/cocos2d/cocos2d-html5/blob/develop/CCBoot.js#L2553)

When everything (the game js-files and the framework-js-files) is minimized, the project.json jsList is empty and therefore _prepared will never be set to true. Normally this is no problem but we use cc.game._prepared in our game (webworkers) to check if the engine is prepared (everything is loaded).

I am not sure but it should be sufficient if self._prepared = true is set here https://github.com/cocos2d/cocos2d-html5/blob/develop/CCBoot.js#L2563 or the project.json contains "jsList": [].

What do you say?

Thanks!

maximdrozd commented 6 years ago

Maybe a better approach would be adding a method to cc.game called isReady() to indicate if everything is loaded. _prepared is "private" var (starts with underscore by convention) - I would no rely on it for any sort of info.