开发者

Cocos2D CClayer removing with bad access

开发者 https://www.devze.com 2023-03-25 02:09 出处:网络
I need to release my layer in update function. I call function finishGame. -(void)finishGame开发者_开发知识库{

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号