I believe this question has been asked before, but it's been quite a while. I currently have a situation where I need to transparently load a large number of identical nodes (maybe 50) in the background of my scene. These nodes are stored in Spritebuilder ccbi files. At the moment, on my slowest devices there is a small but noticeable hiccup when the node loading occurs. Profiling with Xcode Instruments shows that the slowest functions during the hiccup are the CCBReader loading functions.
In order to make the transition more seamless and buttery, I thought of two possible approaches:
- load the nodes from CCB asynchronously. I know Cocos2D doesn't traditionally play well with multithreading, but since I am not really performing anything Cocos2D-ish during the loading from CCB, I might be safe? (I might be in trouble since the ccbi files contain sprites which may need to initialize textures, but could I create an "auxiliary" OpenGL context for the separate thread, similar to what
[CCTextureCache loadImageAsync:] does, to help with this?)
- load one node from CCB, then copy it (most of the nodes I am loading are the same one). I know CCNode does not conform to
NSCopying, but I know there has been talk of this here and there; how difficult would it be to make CCNode conform to NSCopying, and would
[myNode copy] give a significant performance benefit over loading from CCB?
Does anyone have any experience with this kind of situation, or any insight into my two ideas above? Any guidance would be greatly appreciated.