How to access the member variables defined in sub-ccb, from a custom layer class for the main "ccb" file?

How to access the member variables defined in sub-ccb, from a custom layer class for the main “ccb” file ?

Here is the base scenario for this question,


I have a CCB file named “ladybirds_page.ccb” and associate custom loader class as follows (root is a CCLayer)

  • ladybirds_pageLayerLoader.h
  • ladybirds_pageLayer.h
  • ladybirds_pageLayer.cpp

and i have another CCB file named “ladybird.ccb” and associate custom loader class as follows (root is a CCNode)

  • ladybirdLoader.h
  • ladybird.h
  • ladybird.cpp

“ladybirds_page.ccb” file contains several instance of “ladybird.ccb”. And they are associated with relevant member variables (mLadyBird_1,mLadyBird_2,…)

and “ladybird.ccb” it self contains several CCSprites associated with member variable (mDotSprite_1, mDotSprite_2,…)

i want to get the access for these sub-ccb(ladyBird)’s member variable for each instance of it. Like

  • mLadyBird_1~~>mDotSprite_1
    ~~ mLadyBird_1~~>mDotSprite_2

———~~

Here is the my coding approach for this so far,

Create a method names setNumber(int num) in ladyBird.cpp as follows

void ladybird::setNumber(int num)
{
…….
………
mDotSprite_1~~>setVisible;
mDotSprite_1~~>setVisible(false);
……

}

mDotSprite_1 and mDotSprite_1 were assigned using CCB_MEMBERVARIABLEASSIGNER_GLUE macro

CCB_MEMBERVARIABLEASSIGNER_GLUE(this, “mDotSprite_1”, CCSprite **, this~~>mDotSprite_1);
CCB_MEMBERVARIABLEASSIGNER_GLUE;

loading ladybirds_page.ccb file with its custom loader class
void intro_pageLayer::loadNextPage
{
/* Create an autorelease CCNodeLoaderLibrary. /
CCNodeLoaderLibrary
ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary;
ccNodeLoaderLibrary~~>registerCCNodeLoader);
ccNodeLoaderLibrary~~>registerCCNodeLoader);

/* Create an autorelease CCBReader. /
cocos2d::extension::CCBReader
ccbReader = new cocos2d::extension::CCBReader;

/* Read a ccbi file. /
CCNode
node = ccbReader~~>readNodeGraphFromFile;
ccbReader~~>release;
CCScene * scene = CCScene::create;
if {
scene~~>addChild;
}
/** Push the new scene with a fancy transition. */

CCDirector::sharedDirector()~~>pushScene);
}
assign member variable for instance of ladyBirds in ladybirds_pageLayer.cpp

CCB_MEMBERVARIABLEASSIGNER_GLUE;
CCB_MEMBERVARIABLEASSIGNER_GLUE;
and finally, try to call a method setNumber on mLadyBird_1 and mLadyBird_2 as follows
mLadyBird_1~~>setNumber(1);
mLadyBird_2~~>setNumber;

———~~

i got EXC_BAD_ACCESS on

mDotSprite_1->setVisible(false);

Obviously, my scenario was not implemented in my code. So can anybody please enlighten me about the correct way of doing this ?

Thank You.