由于某种原因,在动画运行后,我的CCNode上的删除函数无法工作。
我在单击时添加一个CCNode,运行一个动画,然后运行remove函数。
// loads the Coin
CCNode* coin = [CCBReader load:@"heros/coin"];
coin.name =@"coin";
// position
coin.position = ccpAdd(_touchNode.position, ccp(0, 0));
//Add to Parent
[_touchNode addChild:coin z:-1];
id action1 = [CCActionMoveTo actionWithDuration:0.7f position:ccpAdd(_touchNode.position, ccp(0, 200))];
id action2 = [CCActionMoveTo actionWithDuration:0.7f position:ccpAdd(_touchNode.position, ccp(0, 100))];
CCActionCallFunc *callAfterMoving = [CCActionCallFunc actionWithTarget:self selector:@selector(cleanupSprite:)];
[coin runAction: [CCActionSequence actions:action1, action2, callAfterMoving, nil]];使用下面的delete函数会产生一个This node does not contain the specified child崩溃错误
- (void) cleanupSprite:(CCNode*)inSprite
{
// call your destroy particles here
// remove the sprite
[self removeChild:inSprite cleanup:YES];
}使用以下删除也不起作用
- (void) cleanupSprite:(CCNode*)inSprite
{
// call your destroy particles here
// remove the sprite
[self removeChildByName:@"coin" cleanup:YES];
}发布于 2014-06-06 10:49:11
自我不包含硬币,_touchNode包含硬币。在您的回调中这样做:
[_touchNode removeChildByName:@"coin" cleanup:YES];https://stackoverflow.com/questions/24079476
复制相似问题