本文整理汇总了C++中CCMenuItem::removeFromParentAndCleanup方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItem::removeFromParentAndCleanup方法的具体用法?C++ CCMenuItem::removeFromParentAndCleanup怎么用?C++ CCMenuItem::removeFromParentAndCleanup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItem
的用法示例。
在下文中一共展示了CCMenuItem::removeFromParentAndCleanup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSelectedIndex
void CCMenuItemToggle::setSelectedIndex(unsigned int index)
{
if( index != m_uSelectedIndex && m_pSubItems->count() > 0 )
{
m_uSelectedIndex = index;
CCMenuItem *currentItem = (CCMenuItem*)getChildByTag(kCurrentItem);
if( currentItem )
{
currentItem->removeFromParentAndCleanup(false);
}
CCMenuItem* item = (CCMenuItem*)m_pSubItems->objectAtIndex(m_uSelectedIndex);
this->addChild(item, 0, kCurrentItem);
CCSize s = item->getContentSize();
this->setContentSize(s);
item->setPosition( ccp( s.width/2, s.height/2 ) );
}
}
示例2: onMenu
//.........这里部分代码省略.........
{
tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(CCSizeZero);
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(197);
selectLayer->addChild(tableView);
}
this->m_tableItems->removeAllObjects();
CCArray *existingItems = ((RPGBattleSceneLayer*)this->m_parentNode)->m_existingItems;
for (int i = 0; i < existingItems->count(); i++)
this->m_tableItems->addObject(existingItems->objectAtIndex(i));
tableView->reloadData();
//加载道具数据 end
((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(false);
}
break;
case kRPGBattleMenuTagEscape:
{
// CCLog("逃跑");
float success = CCRANDOM_0_1();
if(success >= 0.0 && success <= 0.5)
{
// CCLog("逃跑成功");
this->setEnabled(false);
this->removeFromParentAndCleanup(true);
((RPGBattleSceneLayer*)this->m_parentNode)->goToMap();
}
else
{
((RPGBattleSceneLayer*)this->m_parentNode)->showMsg((CCString*)this->m_stringList->objectForKey("escape_fail"));
//重置进度条
this->m_playerData->m_progress = 0.0;
CCProgressTimer *battleProgress = (CCProgressTimer*)this->m_parentNode->getChildByTag(kRPGBattleSceneLayerTagPlayerProgress + this->m_playerData->m_dataId);
battleProgress->setPercentage(this->m_playerData->m_progress);
((RPGBattleSceneLayer*)this->m_parentNode)->scheduleUpdate();
CCTMXTiledMap *bgLayer = (CCTMXTiledMap*)this->m_parentNode->getChildByTag(kRPGBattleMenuTagBg);
bgLayer->removeFromParentAndCleanup(true);
this->removeFromParentAndCleanup(true);
}
}
break;
case kRPGBattleMenuTagCancel:
{
// CCLog("取消");
this->showMenu();
CCMenuItem *menuCancel = (CCMenuItem*)this->getChildByTag(kRPGBattleMenuTagCancel);
menuCancel->removeFromParentAndCleanup(true);
switch (this->m_selectedMenuTag)
{
case kRPGBattleMenuTagAttack: