Gah! I can't get 2 ccbi files loaded; I can get only get 1 or the other.


#1

Both ccbi files are structured and working by themselves (I tested each individually). So intuitively I just copied code to get them both; this is apparently not how it’s done?

edit
Shoot; for to mention the assert I’m failing on:
assert(ccNodeLoadersIterator != this~~>mCCNodeLoaders.end);

All I have figured out is that this is NOT the way do handle multiple ccbi files:
<pre>
// create and register node loader library
cocos2d::extension::CCNodeLoaderLibrary* nodeLoader;
nodeLoader = cocos2d::extension::CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary;
nodeLoader~~>registerCCNodeLoader(“SCMainMenuLayer”, SCMainMenuLayerLoader::loader());
nodeLoader~~>registerCCNodeLoader);
// create ccbreader with the default node loaderLibrary
cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader;

// load the main node from the ccbi file
CCNode * node = ccbReader~~>readNodeGraphFromFile(“SCMainMenuCCB.ccbi”);

// add the ccbi node to the scene
if(node != NULL) {
mainMenuScene~~>addChild;
}

// load the main node from the ccbi file
node = ccbReader~~>readNodeGraphFromFile(“SCOverworldCCB.ccbi”);

// add the ccbi node to the scene
if(node != NULL) {
overworldScene~~>addChild;
}

// release the CCBReader instance since we don’t need it anymore
ccbReader~~>release();

Thanks in advance for the help!

#2

Ok, so I got a sort of “hacky” versions working by instantiating a second ccbreader. But this can’t be the “correct” way can it?

// create and register node loader library
    cocos2d::extension::CCNodeLoaderLibrary* nodeLoader;
    nodeLoader = cocos2d::extension::CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();

    nodeLoader->registerCCNodeLoader("SCMainMenuLayer", SCMainMenuLayerLoader::loader());
    nodeLoader->registerCCNodeLoader("SCOverworldLayer", SCOverworldLayerLoader::loader());

    // create ccbreader with the default node loaderLibrary
    cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(nodeLoader);
    cocos2d::extension::CCBReader * ccbReader2 = new cocos2d::extension::CCBReader(nodeLoader);


    // load the main node from the ccbi file
    CCNode * node = ccbReader->readNodeGraphFromFile("SCMainMenuCCB.ccbi");

    // add the ccbi node to the scene
    if(node != NULL) {
        mainMenuScene->addChild(node);
    }


    // load the main node from the ccbi file
    CCNode * node2 = ccbReader2->readNodeGraphFromFile("SCOverworldCCB.ccbi");

    // add the ccbi node to the scene
    if(node2 != NULL) {
        overworldScene->addChild(node2);
    }


    // release the CCBReader instance since we don't need it anymore
    ccbReader->release();
    ccbReader2->release();