About the problem of using "CCMenuItemSprite::itemFromNormalSprite"

Hi, the problem happens on “glDeleteTextures(1, &m_uName)”.
I find the real area is “CCAssert( child->m_pParent == NULL,”child already added. It can’t be added again“)”.

`//Here is the code. start:
CCSpriteFrameCache * cacheCommon = CCSpriteFrameCache::sharedSpriteFrameCache();
cacheCommon-> addSpriteFramesWithFile(“UI2/uiSheet_common.plist”,“UI2/uiSheet_common.png”);
CCSprite *spriteNormal = CCSprite::spriteWithSpriteFrame(cacheCommon->spriteFrameByName(“ban01_1.png”));
CCSprite *spriteClick = CCSprite::spriteWithSpriteFrame(cacheCommon->spriteFrameByName(“ban01_2.png”));

menu_en = (CCMenuItemSprite*)CCMenuItemSprite::itemFromNormalSprite(spriteNormal,spriteClick, this, menu_selector(LanguageSelect::onSelectButtonEn));
+menu_chs = (CCMenuItemSprite*)CCMenuItemSprite::itemFromNormalSprite(spriteNormal,spriteClick, this, menu_selector(LanguageSelect::onSelectButtonChs));
menu_cht = (CCMenuItemSprite*)CCMenuItemSprite::itemFromNormalSprite(spriteNormal,spriteClick, this, menu_selector(LanguageSelect::onSelectButtonCht));+

CCMenu *menu = CCMenu:: menuWithItems(menu_en,menu_chs,menu_cht,NULL);
menu->setPosition(CCPointZero);
this->addChild(menu);

//“LanguageSelect::onSelectButtonEn” is here. Other is similar to this.
void LanguageSelect::onSelectButtonEn(CCObject* pSender){
text_en->setIsVisible(true);
text_chs->setIsVisible(false);
text_cht->setIsVisible(false);
text_04->setIsVisible(false);

text_enShadow->setIsVisible(true);
text_chsShadow->setIsVisible(false);
text_chtShadow->setIsVisible(false);
text_04Shadow->setIsVisible(false);

language_type = LANGUAGE_EN;

CCTransitionFade* trans = CCTransitionFade::transitionWithDuration(1.0, LogoTouch::scene());
    CCDirector::sharedDirector() -> replaceScene( trans);

}
//end`

The problem lies in the underlined code,and the problem is show in the picture.


addChild.jpg (41.4 KB)


problem1.jpg (33.4 KB)


problem2.jpg (63.8 KB)


addChild.jpg (41.4 KB)


problem1.jpg (33.4 KB)


problem2.jpg (63.8 KB)

I have found the reason.The pointers (“spriteNormal,spriteClick”) do not allow repeated adding.So a number of different pointers should be declared.

oh, you give me a lesson! I haven’t know it’s a tip of cocos2d yet.
I apologize that I didn’t review this crash in last night. Thanks for your resolution!