0
请帮助我,我是一个初学者在cocos2d-x。 我有物品清单。 我怎样才能做到这一点使用CCMenu :: createWithArray在最后显示这个列表的项目数组? 我想控制菜单数组,从数组中添加/删除项目(从我的列表菜单)。获取项目数组。使用CCMenu :: createWithArray
这里是代码:
`` ...
CCLabelTTF* pp0BtnLabel = CCLabelTTF::create(string(ItemName[0]).c_str(), "Arial", TITLE_FONT_SIZE);
CCMenuItemLabel *pp0Item = CCMenuItemLabel::create(
pp0BtnLabel,
this,
menu_selector(Window::CheckItemCallback));
pp0Item->setTag(ItemTag[0]);
CC_BREAK_IF(! pp0Item);
pp0Item->setPosition(ccp(size.width*0.3f, size.height*0.8));
CCLabelTTF* pp1BtnLabel = CCLabelTTF::create(string(ItemName[0]).c_str(), "Arial", TITLE_FONT_SIZE);
CCMenuItemLabel *pp1Item = CCMenuItemLabel::create(
pp1BtnLabel,
this,
menu_selector(Window::CheckItemCallback));
pp1Item->setTag(ItemTag[0]);
CC_BREAK_IF(! pp1Item);
pp1Item->setPosition(ccp(size.width*0.3f, size.height*0.75));
CCLabelTTF* pp2BtnLabel = CCLabelTTF::create(string(ItemName[0]).c_str(), "Arial", TITLE_FONT_SIZE);
CCMenuItemLabel *pp2Item = CCMenuItemLabel::create(
pp2BtnLabel,
this,
menu_selector(Window::CheckItemCallback));
pp2Item->setTag(ItemTag[0]);
CC_BREAK_IF(! pp2Item);
pp2Item->setPosition(ccp(size.width*0.3f, size.height*0.7));
CCMenu* pMenuChapter = CCMenu::create(pp0Item, pp1Item, pp2Item, NULL);
pMenuChapter->setPosition(CCPointZero);
CC_BREAK_IF(! pMenuChapter);
this->addChild(pMenuChapter, 1);
...
``
非常感谢你! – user2077802 2013-02-16 08:21:32
不客气。如果您发现anwser有用,请投票;) – 2013-02-16 14:37:19