Hey, the dealloc method does get called in cpCCNodeImpl.m when switching from the menu to the gamescene and gamescene to menu. I tested it by adding this:
-(void) dealloc
{
NSLog(@"calling dealloc in: cpCCNodeImpl");
if (_shape)
{
NSLog(@"calling dealloc with if in: cpCCNodeImpl");
_shape->data = NULL;
if (_autoFreeShape)
NSLog(@"calling autoFreeShape in: cpCCNodeImpl");
[_spaceManager scheduleToRemoveAndFreeShape:_shape];
}
_shape = nil;
[super dealloc];
}
But when switching to the menu from the gamescene i get an EXC_BAD_ACCESS, heres the backtrace:
2011-01-29 12:01:41.828 funky truck 3.0[21965:307] game is being deallocated
2011-01-29 12:01:41.877 funky truck 3.0[21965:307] calling autoFreeShape in: cpCCNodeImpl
Program received signal: “EXC_BAD_ACCESS”.
(gdb) bt
#0 0x339737d8 in objc_msgSend ()
#1 0x00009364 in -[cpCCNodeImpl dealloc] (self=0x25c910, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/src/cpCCNodeImpl.m:43
#2 0x34411532 in -[NSObject(NSObject) release] ()
#3 0x000089d8 in -[cpCCNode dealloc] (self=0x25c7f0, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/src/cpCCNode.m:31
#4 0x34411532 in -[NSObject(NSObject) release] ()
#5 0x34415984 in CFRelease ()
#6 0x3443bedc in -[__NSArrayM dealloc] ()
#7 0x34411532 in -[NSObject(NSObject) release] ()
#8 0x0009a910 in -[CCNode dealloc] (self=0x24cdb0, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCNode.m:254
#9 0x34411532 in -[NSObject(NSObject) release] ()
#10 0x34415984 in CFRelease ()
#11 0x3443bedc in -[__NSArrayM dealloc] ()
#12 0x34411532 in -[NSObject(NSObject) release] ()
#13 0x0009a910 in -[CCNode dealloc] (self=0x25b170, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCNode.m:254
#14 0x00006be4 in -[HelloWorld dealloc] (self=0x25b170, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/Classes/HelloWorldScene.m:393
#15 0x34411532 in -[NSObject(NSObject) release] ()
#16 0x34415984 in CFRelease ()
#17 0x3443bedc in -[__NSArrayM dealloc] ()
#18 0x34411532 in -[NSObject(NSObject) release] ()
#19 0x0009a910 in -[CCNode dealloc] (self=0x245190, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCNode.m:254
#20 0x34411532 in -[NSObject(NSObject) release] ()
#21 0x000f0c70 in -[CCTransitionScene dealloc] (self=0x27cc80, _cmd=0x32ca2574) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCTransition.m:168
#22 0x34411532 in -[NSObject(NSObject) release] ()
#23 0x000745d8 in -[CCDirector setNextScene] (self=0x245f10, _cmd=0x10ab0f) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCDirector.m:747
#24 0x0007169c in -[CCDirector mainLoop] (self=0x245f10, _cmd=0x10ac2a) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCDirector.m:241
#25 0x00075f40 in -[CCDisplayLinkDirector preMainLoop:] (self=0x245f10, _cmd=0x10a94e, sender=0x24f770) at /Users/svp/Documents/funky truck 3.0/libs/cocos2d/CCDirector.m:1111
#26 0x3072d702 in CA::Display::DisplayLink::dispatch ()
#27 0x3072d826 in CA::Display::IOMFBDisplayLink::callback ()
#28 0x305d3bfa in IOMobileFramebufferVsyncNotifyFunc ()
#29 0x3404c046 in ?? ()
#30 0x34448312 in __CFMachPortPerform ()
#31 0x3443fce2 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#32 0x3443fca6 in __CFRunLoopDoSource1 ()
#33 0x3443256c in __CFRunLoopRun ()
#34 0x34432276 in CFRunLoopRunSpecific ()
#35 0x3443217e in CFRunLoopRunInMode ()
#36 0x3026b5f2 in GSEventRunModal ()
#37 0x3026b69e in GSEventRun ()
#38 0x31ad0122 in -[UIApplication _run] ()
#39 0x31ace12e in UIApplicationMain ()
#40 0x00002920 in main (argc=1, argv=0x2ffff558) at /Users/svp/Documents/funky truck 3.0/main.m:13