I try to mimic the “tests” menu in controller.cpp from cocos2dx example.
———————- My code to render the menu ——————————————
CCMenu itemMenu = CCMenu::menuWithItems;
for{
CCLabelTTFlabel = CCLabelTTF::labelWithString(“KKKK”,“Arial”,24);
label~~>setColor);
label~~>setPosition(ccp(150,150+i*150));
CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label,this,menu_selector(MainMenuLayer::menuCallback));
itemMenu~~>addChild;
}
itemMenu~~>setContentSize(CCSizeMake(screenSize.width/2,500));
itemMenu->setPosition(ccp(150,150));
setIsTouchEnabled(true);
addChild(itemMenu);
————————— my callback function ————————————————
void MainMenuLayer::menuCallback(CCNode* sender){
CCLog(“[DEBUG] menuCallback”);
}
The execution shows the right effect what i expect (two item named “KKK”).
However, when I pressed the “KKKK” label, cocos2dx doesn’t call my callback function?(I don’t receive the logcat msg)
Can anyone help me? thanks