0.0 0


Hi, I’m new in cocos2dx. And my problem is that a start to miss the id in objC (possible in cocos2d). Well, this is my problem. I got 2 layers, work together in a scene. So I want layerA send a message to layerB to update a sprite (child of layerB of course). Im working with this 2 layers, cause I want a userInterface generic layer, that could be able to work in all levels (that for me, are scenes). So, ’if a have id in cocos2dx, simply send a message from layerA to its parent (and in this point is the big black hole, I have to know who is its parent, and I want this layer be totally generic). Any suggestion??? Greetings


CCNode::getChildByTag, CCNode::getTag, CCNode::setTag would be helpful in your situation.
I write the sample code for you, but haven’t build and test it

// in a method of layerB
#define TAG_LAYER_A 123
#define TAG_LAYER_B 456

CCScene* pScene = CCDirector::sharedDirector()->getRunningScene();
CCLayer* pLayerA = (CCLayer*)( pScene->getChildByTag(TAG_LAYER_A) );

And don’t forget to setTag in the init phase of layerA & B.


Thanks a lot!