For some reason the dealloc of my CCLayer is not fired when replacing the scene. Here is the code to replace the scene:
[[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:2.0f scene:[HelloWorld scene]]];
The above code is triggered when I press a button.
I have placed a NSLog inside the dealloc method which is never triggered.
UPDATE 1:
I ended up solving the problem by manually releasing the memory just before replacing the scene.
When I first time begun to use cocos2d I had encountered this exactly same problem. In my case I'm added as targeted delegate the self and that means that reference count to the self was increased.
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:2]swallowsTouches:NO];
And I solved this by removing all delegates(also you can specify particular delegate) :
[[CCTouchDispatcher sharedDispatcher] removeAllDelegates];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With