首页 > 代码库 > cocos2dx 菜单按钮回调方法传参 tag传参

cocos2dx 菜单按钮回调方法传参 tag传参

.h文件

void menuCallBack(CCObject* pSender);

 .cpp

CCMenuItemSprite* item = CCMenuItemSprite::create(                                                      menuCB1,                                                      menuCB2,                                                      this,                                                      menu_selector(helloworld::menuCallBack));item->setTag(m);    

 回调方法

void helloworld::menuCallBack(CCObject* pSender){    CCNode* node = dynamic_cast<CCNode*>(pSender);    CCLog("【====PopupLayer::buttonCallBack====】touch tag: %d", node->getTag());}

 获取点击的菜单按钮tag