本文整理汇总了C++中CCMenu::removeFromParent方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenu::removeFromParent方法的具体用法?C++ CCMenu::removeFromParent怎么用?C++ CCMenu::removeFromParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenu
的用法示例。
在下文中一共展示了CCMenu::removeFromParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTexture
// Helper
bool CCRichLabelTTF::updateTexture()
{
CCTexture2D_richlabel *tex;
tex = new CCTexture2D_richlabel();
if (!tex)
return false;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
ccRichFontDefinition texDef = _prepareTextDefinition(true);
tex->initWithRichString( m_string.c_str(), &texDef );
#else
tex->initWithRichString( m_string.c_str(),
m_pFontName->c_str(),
m_fFontSize * CC_CONTENT_SCALE_FACTOR(),
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
m_hAlignment,
m_vAlignment);
#endif
// set the texture
this->setTexture(tex);
// release it
tex->release();
// set the size in the sprite
CCRect rect =CCRectZero;
rect.size = _texture->getContentSize();
this->setTextureRect(rect);
// create link menu
CCMenu* menu = (CCMenu*)getChildByTag(TAG_MENU);
const LinkMetaList& linkMetas = tex->getLinkMetas();
if(!linkMetas.empty() && m_textChanging) {
// delete old menu if has
if(menu) {
menu->removeFromParent();
menu = NULL;
}
// now create items for every link
//CCArray* items = CCArray::create();
Vector<MenuItem*> items;
for(LinkMetaList::const_iterator iter = linkMetas.begin(); iter != linkMetas.end(); iter++) {
const LinkMeta& meta = *iter;
CCMenuItemColor* item = CCMenuItemColor::create(ccc4FromInt(meta.normalBgColor),
ccc4FromInt(meta.selectedBgColor),
this,
menu_selector(CCRichLabelTTF::onLinkMenuItemClicked));
item->setTag(START_TAG_LINK_ITEM + meta.tag);
item->setPosition(ccp(meta.x + meta.width / 2,
meta.y + meta.height / 2));
item->setContentSize(CCSizeMake(meta.width, meta.height));
item->setStateListener(m_stateListener);
items.pushBack(item);
}
// add menu in -1 z order so that it won't override label UI
CCMenu* newMenu = CCMenu::createWithArray(items);
newMenu->setPosition(CCPointZero);
addChild(newMenu, -1, TAG_MENU);
// clear flag
m_textChanging = false;
}
// sync shadow stroke padding to link menu
// the padding must divide scale factor. Because at this time, texture already scaled for label
menu = (CCMenu*)getChildByTag(TAG_MENU);
if(menu) {
const CCPoint& p = tex->getShadowStrokePadding();
menu->setPosition(ccp(p.x / CC_CONTENT_SCALE_FACTOR(),
p.y / CC_CONTENT_SCALE_FACTOR()));
}
//ok
return true;
}