I am having a strange problem. I’m not sure if it is to do with Cocos2d-x or OSX / iOS.
I am finding that sometimes the files in the Resources folder are not available to load in time when the application runs. For example, a texture or a json data file may not exist, but if I wait for a short time (or even just put a breakpoint in and then resume execution) then they will be there. I found that by waiting until after the main Scene’s init() function was called before I loaded my data, then it would be there in time, but on an iOS device it is still not ready.
I can’t see any other mention of this on the forum which makes me think I’m doing something weird. It seems like the file is either there or not, and should be available right away. Has anyone else seen this?
Extra information:
This is happening both using Cocos2d-x functions like Label::create(…) and Sprite::create(…) as well as with standard code like this:
Thanks for the tips, @pabitrapadhy, but I’m pretty sure that my problem is not related to those issues. It’s really weird that the assets are only missing sometimes, and that it appears to be time-related, ie they become available after a delay.
Hi, I eventually figured out that I had an initialisation problem, although I did find out that on OSX / iOS, the resources are not available until after applicationDidFinishLaunching() is called, which does answer the original question, (and was something I didn’t know.) The way Cocos2d-x is set up, it’s pretty hard to do anything before that anyway, at least for anything in the Cocos api.
@pabitrapadhy - Thanks for taking the time to help out.