我有最新的cocos2d、Xcode4和iOS5 SDK。我正在 iPhone 4 (5.0.1) 上测试我的应用程序。模拟器上不会发生崩溃 - 仅在设备上发生。
第一次运行时,我的应用程序在进入第一个场景之前崩溃了,这是由 CCTransitionFade 完成的。它在 CCLayer 中崩溃:
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
如果我再次加载应用程序,它会正常启动 - 不会崩溃。
我删除了 CCTransition 并在没有转换的情况下启动了第一个场景,并且在第一次运行时没有遇到崩溃(太棒了!)。然而,在游戏过程中,我在游戏场景顶部放置了一个颜色层,并将颜色层的不透明度降至 50% 左右。游戏在这里崩溃。
这些崩溃仅在应用程序首次运行时发生。两次崩溃都有不透明度褪色的共同点。两次崩溃都在 CCLayer 中的同一行失败。
此崩溃发生在 iPhone 4 (iOS 5.0.1) 和 iPad (iOS 5.0.1) 上,但不是 iPhone 4 (iOS 4.2.1)。
有人有什么想法、想法或建议吗?我完全迷失了!
通过 xcode 在设备上运行的调试版本,启动时崩溃:
Mar 6 23:36:53 unknown Boco[10699] : cocos2d: surface size: 640x960
Mar 6 23:37:08 unknown securityd[10702] : MS:Notice: Installing: (null) [securityd] (675.00)
Mar 6 23:37:08 unknown ReportCrash[10700] : MS:Notice: Installing: (null) [ReportCrash] (675.00)
Mar 6 23:37:09 unknown ReportCrash[10700] : Formulating crash report for process Boco[10699]
Mar 6 23:37:09 unknown com.apple.launchd[1] : (UIKitApplication:com.sunlight.boco[0x79a]) Bug: launchd_core_logic.c:3730 (25147):3
Mar 6 23:37:09 unknown com.apple.launchd[1] : (UIKitApplication:com.sunlight.boco[0x79a]) Assuming job exited: : 10: No child processes
Mar 6 23:37:09 unknown com.apple.launchd[1] : (UIKitApplication:com.sunlight.boco[0x79a]) Job appears to have crashed: Segmentation fault: 11
Mar 6 23:37:09 unknown SpringBoard[10505] : Application 'boco' exited abnormally with signal 11: Segmentation fault: 11
Mar 6 23:37:09 unknown ReportCrash[10700] : Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Boco_2012-03-06-233708_James-iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
在设备上临时运行的发布版本,在颜色层不透明度更改时崩溃
Mar 6 23:57:40 unknown ReportCrash[343] : MS:Notice: Installing: (null) [ReportCrash] (675.00)
Mar 6 23:57:41 unknown ReportCrash[343] : Formulating crash report for process Boco[338]
Mar 6 23:57:41 unknown com.apple.launchd[1] : (UIKitApplication:com.sunlight.boco[0xe5d6]) Job appears to have crashed: Bus error: 10
Mar 6 23:57:41 unknown SpringBoard[28] : Application 'boco' exited abnormally with signal 10: Bus error: 10
Mar 6 23:57:41 unknown ReportCrash[343] : Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Boco_2012-03-06-235740_James-iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
最佳答案
没有找到这个问题的解决方案(参见 http://www.cocos2d-iphone.org/forum/topic/29958?replies=10#post-147371 ),所以我创建了一个新的 xcode 项目并将我的所有代码移植过来。问题解决了!
关于cocoa - Cocos2d 仅在首次运行应用程序时在 CCLayer 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9583442/