Build cocos objects in second thread

Hi,
I’m trying to build my scene in second thread so cocos thread won’t be locked and user can still work with application/game. Is there a way to do that with cocos memory management?

OpenGL is not thread safe too.
So you can not build a scene in another thread.

@zhangxm wrote:

OpenGL is not thread safe too.
So you can not build a scene in another thread.

@zhangxm
so even if I will replace scene in cc thread it is impossible to build it(or other objects like sprites, particles) in second thread because some glThread functions are invoked during objects initialization?

Yep, you are right.
And cocos2d-x is not thread safe too.
Not only because the memory management.

@ zhangxm thanks for the information.

It would be great if you could answer one more question :slight_smile:
I want to make an animated “Loading screen” during resources initialization or building levels of the game, so is there a way to build scene/layer/sprite/animation which can be updated while building the next game scene or other objects in cc thread?

I don’t know if you use iOS/Android to system API to do Loading screen. If so, i think you can use Schedule::performFunctionInCocosThread() to build scene/layer/sprite/animation.

Or you can use TextureCache::addImageAsync() to load image in another thread.