문제

Hello I am making a Cocos2d side scroller. I have a CCSprite that I add using the [self addChild:sprite]; method. After a while I want the CCSprite to be removed. I tried the [self removeChild:sprite cleanup:YES]; method and it gave me a thread bad access error. Is this the only way to remove a child in Cocos2d?? Is there an alternate way?? I am a beginner to Cocos2d and objective c so any help is valuable.

도움이 되었습니까?

해결책

As far as I know, removeChild:cleanup: is the way to go if you need to remove any CCNode. Have you checked that sprite is not released before trying to remove it?

다른 팁

[sprite removeFromParentAndCleanUp:YES]

If you have a bad access it means object is nill. Check if your sprite exist before you try to remove it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top