Cocos2d Game crashes when trying to replace scene

283 views Asked by At

I am trying to switch between different scenes in my game. I switched from my GameLayer to a Config scene first, then switch back using the following code, but the game crashes:

-(void) backToGame
{
    [[CCDirector sharedDirector] replaceScene:[GameLayer scene]];
}

And the log I received:

thread #1: tid = 0x1c03, 0x350ebf78 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=1, address=0xe0000008)
    frame #0: 0x350ebf78 libobjc.A.dylib`objc_msgSend + 16
    frame #1: 0x373352e6 CoreFoundation`CFRelease + 94
    frame #2: 0x373b1b36 CoreFoundation`__CFDictionaryStandardReleaseValue + 70
    frame #3: 0x374053bc CoreFoundation`__CFBasicHashDrain + 264
    frame #4: 0x3733539a CoreFoundation`CFRelease + 274
    frame #5: 0x350eee56 libobjc.A.dylib`objc_release + 38
(lldb) 

I am sorry that I cannot attach any more codes from my project because I really don't know where it comes from.

Thanks for your help.

1

There are 1 answers

1
Guru On

Try this lines of code.

[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[GameLayer scene] withColor:ccWHITE]];