About using sub-ccbs

Hello! This is my first time posting a message here and I hope someone can help me with my problem. I am a new cocos2dx programmer so I am not really familiar with how to do things. This may mean I may have missed some things. Anyway, the problem is, I have a main CCB file (play.ccb) in cocosbuilder that has a SubCCB (overlay.ccb) in it.

The SubCCB has no animations whatsoever. In the main CCB, I animated the CCBNode for some changes in position. When I try to run the app I get pointed here in CCBReader.cpp

    // Handle sub ccb files (remove middle node)
    if (dynamic_cast(node))
    {
        CCBFile *ccbFileNode = (CCBFile*)node;

        CCNode *embeddedNode = ccbFileNode->getCCBFileNode();
        embeddedNode->setPosition(ccbFileNode->getPosition());      <-----HERE
        embeddedNode->setRotation(ccbFileNode->getRotation());
        embeddedNode->setScale(ccbFileNode->getScale());
        embeddedNode->setTag(ccbFileNode->getTag());
        embeddedNode->setVisible(true);
        embeddedNode->ignoreAnchorPointForPosition(ccbFileNode->isIgnoreAnchorPointForPosition());

        mActionManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);

        ccbFileNode->setCCBFileNode(NULL);

        node = embeddedNode;
    }

Xcode tells me that I get “EXC_BAD_ACCESS Code=2” there

In the console I get, Cocos2d: get data from file(overlay.ccbi) failed!

I read somewhere that this error means that cocos2d cannot find the file (overlay.ccbi)
The subCCB file (overlay.ccb) is connected to its correct custom class. This is the same for the main CCB.

Am I missing something? Am I failing to do something? Thank you for your help in advance :smiley:

Attach the debugger and figure out which of those two casted objects is messed up.

Hmm…

The thing is I am running the app on the simulator. I tried to attach the debugger but it says that it is already being debugged.

The culprit is GSPlayScene::init() which uses the play.ccb that has a sub ccb in it (overlay.ccb).

It goes through the CCBReader and ends where it is shown in my first post. The console is also showing that it cannot find/load the overlay.ccbi file. I am sure that I have the said file in the right directory and it is properly included in the project file.

Cory Trese wrote:

Attach the debugger and figure out which of those two casted objects is messed up.

Do you know how to load a ccb file that has a sub ccb file in it? I may have been messing up the basics.

Hi ,

Have you got solution? I am also trying to use a ccbi file that has a ccbi file in it.

my problem is : http://www.cocos2d-x.org/boards/6/topics/34240

Please share if you got any idea.

Thanks.