Animated (multithreaded?) loading screen

Hi there,

by now i have some experience in both cocos2d-x and pthreads and i would like to have a loading scene that has a background thread loading all the assets.

Problem is that i’ve read somewhere that cocos2d-x is not designed to be used with multithreading and it could have problems with the autorelease pool… is that right?
Is there any standard practice to do a loading screen in cocos2d-x or cocos2d (can read objective c if needed)?

Actually i’m using cocos2d-x 2.0.1 rc2 as i’m at the end of a project and can’t update right now.

Thank you!

CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallFuncO selector); This method has wrapped multi-thread in it.
About Loading Scene, we have a issue #1345, but have no enough time to do it. I appreciate if you can implement and contribute this feature. You can simply show the percentage on a CCProgressTimer

I’ve read the issue but i did not understand it… is it a feature request maybe?

Thing is that by now i’m using third party tools (LevelHelper) and i can’t assume they will use this method or look for every texture loading code and change it…

In any case, would it be any problem to create a thread (normal pthread_create()) and do a CCSprite::create(“awesomeTexture.png”)? A memory leak maybe?
If there isn’t any problem i could just create a thread, do the loading in it and that’s it.

I don’t mind problems like trying to load 2 textures at the same time as i won’t be doing this. That loading screen would just be waiting for a bool loaded variable to be true and then change the scene.
I would even try to create the scene and return it from the thread so i can just simply replace it when the loading is done.

Thanks

Bumping this thread to see if anybody can put some light into it…

Walzer Wang wrote:

CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallFuncO selector); This method has wrapped multi-thread in it.
About Loading Scene, we have a issue #1345, but have no enough time to do it. I appreciate if you can implement and contribute this feature. You can simply show the percentage on a CCProgressTimer

Hi, I recently have a problem about the method: CCTextureCache::addImageAsync(const char path, CCObjecttarget, SEL_CallFuncO selector);
It leaks a .png file’s size.
Can you give me a hand?

http://www.cocos2d-x.org/boards/6/topics/17031?r=17042#message-17042

THX!~

Hi guys…any updates on how to implement this? Thanks.