Method to add Custom Class for an child of root CCLayer

Method to add Custom Class for an child of root CCLayer
0.0 0


This has been posted to Cocos2d-iphone/tools forum but it seems that nobody know this. So I repost it here.

I’m using cocos2d-x. Inside MAIN CCB:

CCLayer (Custom class - MainScene)

  • sub-ccb (SubScene)
  • child - sprite (ItemNode)

Inside SubScene:

CCNode (Custom class - SubScene)

The ItemNode property:

CCNode (Custom class - ItemNode)

When I’m loading MainScene.ccbi, the app crashes in assert

CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(const char* pClassName) {
CCNodeLoaderMap::iterator ccNodeLoadersIterator = this~~>mCCNodeLoaders.find;
return ccNodeLoadersIterator~~>second;

The pClassName is “SubScene”. That means the program crashes when it loads the “SubScene”. I think the problem is I don’t have a SubSceneLoader to register. (Even I can define a loader, I don’t know how to register it).

Any idea? Thanks


Finally I found a method to do this. I should register all loaders first when I load the ccbi file.

I can load ccbi dynamically and use custom class for sub-ccb at last. I’m planing to write a tutorial somewhere in near future.