Help me! My Object is not removeChild!


#1

I want a make object that removeChild itself.

so I expend CCSprite.

but it is not removeChild. I don’t know Why.

Please help me

Code
void GamePlay::updateGame(ccTime dt)
{
target~~>destroyed;
}
void Huddle::destroyed
{
motion_state = HUDDLE::_DESTROYED;
// 허들의 모든 액션을 중지한다.
this~~>stopAllActions();

// destroyed Animation
CCAnimation* animation = CCAnimation::animation();
{
char str[100] = {0};
for(int i = 1; i < 5; i++)
{
sprintf(str, “s/arc2402d.png”,s_player2_path , i);
//CCLog(“run sprite str is %s”, str);
animation~~>addFrameWithFileName;
this~~>setFlipX(true);
}

}
CCActionInterval destroed_ani = CCAnimate::actionWithDuration;
// CCCallFuncND형 변수로 만들어야 제대로 실행이 된다.
CCCallFuncND
pCCCallFuncND = CCCallFuncND::actionWithTarget(this, callfuncND_selector(Huddle::destroyedFinish), (void**)pParent );
CCFiniteTimeAction** seq = CCSequence::actions(destroed_ani, pCCCallFuncND, NULL);
CCActionInterval* action = (CCActionInterval**) seq;
action~~>setTag;
this~~>runAction;
}
void Huddle::destroyedFinish
{
**//It is not removeChild. It is not Work!*
// void*으로 받아온 데이터를 원래 원형인 CCNode*로 받아온다.
CCNode* parent = (CCNode*) pParent;
parent->removeChild(this, true);

}


스크린샷 2012-02-02 오후 7.44.54.png (91.3 KB)


#2

Please see the callback declare, it’s ‘typedef void (CCObject::*SEL_CallFuncND)(CCNode**, void**);’
But your callback is ‘void Huddle::destroyedFinish(void* pParent)’, it should be ‘void Huddle::destroyedFinish(CCNode* sender, void* pParent)’.


#3

Thank you so much.:slight_smile:
Thank you.

James Chen wrote:

Please see the callback declare, it’s ‘typedef void (CCObject::*SEL_CallFuncND)(CCNode**, void**);’
But your callback is ‘void Huddle::destroyedFinish(void* pParent)’, it should be ‘void Huddle::destroyedFinish(CCNode* sender, void* pParent)’.