【问题标题】:Cocos2d Game crashes when trying to replace scene尝试替换场景时 Cocos2d 游戏崩溃
【发布时间】:2012-11-17 14:48:54
【问题描述】:

我正在尝试在游戏中的不同场景之间切换。我首先从我的 GameLayer 切换到 Config 场景,然后使用以下代码切换回来,但游戏崩溃了:

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

我收到的日志:

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) 

很抱歉,我无法从我的项目中附加更多代码,因为我真的不知道它来自哪里。

感谢您的帮助。

【问题讨论】:

  • 你启用了 NSZombie 吗?
  • 哦,我不知道。谷歌搜索并启用它,立即找到我的问题。非常感谢!

标签: ios cocos2d-iphone msgsend


【解决方案1】:

试试这行代码。

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

【讨论】:

  • 感谢您的回复,但我已经通过使用 NSZombie 找到并解决了 pbm。这是我的代码中的一些其他内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-19
  • 1970-01-01
  • 2021-07-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多