This is my code:
if (countTime == 20)
{
[self removeChild:starMenu cleanup:YES];
shootIntervalLevel = 5;
[self schedule:@selector(shootCountDown:) interval:1.0f];
}
- (void)shootCountDown:(ccTime)dt {
shootIntervalLevel--;
if (shootIntervalLevel == 0)
{
[self addChild:starMenu];
[self unschedule:@selector(shootCountDown:)];
}
}
I remove a child (menu) after a countdown, and try adding it back again when the time is up. Problem is, it won't re-add after the time is expired. It removes it fine, but it doesn't seem to want to come back.
I get this error in console: *** Assertion failure in -[GameScene addChild:z:tag:], /Users/markdas/Documents/BasicGame/libs/cocos2d/CCNode.m:360, which points to
NSAssert( child.parent == nil, @"child already added. It can't be added again");
It's being removed first, so why am I getting this error?