Cocos2D CClayer removing with bad access
I need to release my layer in update function. I call function finishGame.
-(void)finishGame开发者_开发知识库{
[[CCDirector sharedDirector] pause];
[layerRoot removeFromParentAndCleanup:YES];
[layerRoot autorelease];
layerRoot=nil;
}
But then i got either bad access notification
// updates with priority == 0
DL_FOREACH_SAFE( updates0, entry, tmp ) {
if( ! entry->paused )
entry->impMethod( entry->target, updateSelector, dt ); //<<< In this string.
}
or return 0; 0_o This is very strange. Because program can not be finished.
What do I wrong?
Thanks so much.
[obj removeFromParentAndCleanup:YES] releases the object in question. You shouldn't call anything on the object after you call that method, unless you specify NO. You can still set it to nil, though, that's just good Objective-C coding practice.
Also: If you subclassed CCNode properly, they autorelease anyway.
精彩评论