我遵循Harry的cocos3d教程。
新建一个名为shapes的helloworld模板项目:
它完美运行。
然后我重命名shapesLayer:refactor->将其重命名为MainLayer。
应用程序崩溃:
cocos2d: cocos2d-iphone v2.1
cocos2d: compiled with Profiling Support: NO
cocos2d: OS version: 7.1 (0x07010000)
cocos2d: GL_VENDOR: Apple Computer, Inc.
cocos2d: GL_RENDERER: Apple Software Renderer
cocos2d: GL_VERSION: OpenGL ES 2.0 APPLE-9.4.3
cocos2d: GL_MAX_TEXTURE_SIZE: 4096
cocos2d: GL_MAX_TEXTURE_UNITS: 8
cocos2d: GL_MAX_SAMPLES: 4
cocos2d: GL supports PVRTC: YES
cocos2d: GL supports BGRA8888 textures: YES
cocos2d: GL supports NPOT textures: YES
cocos2d: GL supports discard_framebuffer: YES
cocos2d: GL supports shareable VAO: NO
2014-08-31 11:25:11.966 shapes[9466:60b] cocos2d: viewDidLoad
2014-08-31 11:25:11.967 shapes[9466:60b] cocos2d: animation started with frame interval: 60.00
2014-08-31 11:25:11.969 shapes[9466:60b] cocos2d: surface size: 640x960
[***ERROR***] MainLayer on (null) could not determine the appropriate class to instantiate to automatically populate the cc3Scene property.
2014-08-31 11:25:11.970 shapes[9466:60b] *** Assertion failure in -[MainLayer cc3SceneClass], /Users/yetao/Documents/shapes/cocos3d/cocos3d/cocos3d/Scenes/CC3Layer.m:106
2014-08-31 11:25:11.973 shapes[9466:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'See previous logged error.'
*** First throw call stack:
(
0 CoreFoundation 0x0298f1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0270e8e5 objc_exception_throw + 44
2 CoreFoundation 0x0298f048 +[NSException raise:format:arguments:] + 136
3 Foundation 0x006ea4de -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 shapes 0x0005f565 -[CC3Layer cc3SceneClass] + 949
5 shapes 0x0005eff0 -[CC3Layer cc3Scene] + 80
6 shapes 0x00060ab3 -[CC3Layer updateViewport] + 611
7 shapes 0x00060718 -[CC3Layer contentSizeChanged] + 88
8 shapes 0x0005e50d -[CCLayer(CC3) setContentSize:] + 269
9 shapes 0x001ddeac -[CCLayer init] + 252
10 shapes 0x0005f6c6 -[CC3Layer init] + 86
11 shapes 0x0005e3e5 +[CCLayer(CC3) layer] + 69
12 shapes 0x0000412a -[AppDelegate application:didFinishLaunchingWithOptions:] + 586
13 UIKit 0x017ee14f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
14 UIKit 0x017eeaa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
15 UIKit 0x017f3667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
16 UIKit 0x01807f92 -[UIApplication handleEvent:withNewEvent:] + 3517
17 UIKit 0x01808555 -[UIApplication sendEvent:] + 85
18 UIKit 0x017f5250 _UIApplicationHandleEvent + 683
19 GraphicsServices 0x03ebcf02 _PurpleEventCallback + 776
20 GraphicsServices 0x03ebca0d PurpleEventCallback + 46
21 CoreFoundation 0x0290aca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
22 CoreFoundation 0x0290a9db __CFRunLoopDoSource1 + 523
23 CoreFoundation 0x0293568c __CFRunLoopRun + 2156
24 CoreFoundation 0x029349d3 CFRunLoopRunSpecific + 467
25 CoreFoundation 0x029347eb CFRunLoopRunInMode + 123
26 UIKit 0x017f2d9c -[UIApplication _run] + 840
27 UIKit 0x017f4f9b UIApplicationMain + 1225
28 shapes 0x00003d2c main + 92
29 shapes 0x00002cd5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) instantiate to automatically populate the cc3Scene property
我调试了它:
CC3Layer* cc3Layer = [MainLayer layer];
它只是崩溃......
我将它重命名为shapesLayer。它可以工作。
那么如何重命名以及崩溃的原因呢?
答案 0 :(得分:0)
我对CC3Layer.m无言以对:
他们需要共享相同的前缀。
MainLayer-> MainScene。 shapesLayer-> shapesScecne。
-(Class) cc3SceneClass {
Class sceneClass = nil;
NSString* baseName = nil;
NSString* layerClassName = NSStringFromClass(self.class);
// If layer class name ends in "Layer", strip it and try some combinations
if ( [layerClassName hasSuffix: @"Layer"] ) {
baseName = [layerClassName substringToIndex: (layerClassName.length - @"Layer".length)];
// Try HelloLayer -> HelloScene
sceneClass = NSClassFromString([NSString stringWithFormat: @"%@Scene", baseName]);
if (sceneClass && [sceneClass isSubclassOfClass: CC3Scene.class]) return sceneClass;
// Try HelloLayer -> Hello
sceneClass = NSClassFromString(baseName);
if (sceneClass && [sceneClass isSubclassOfClass: CC3Scene.class]) return sceneClass;
}
// Try Hello -> HelloScene (including HelloLayer -> HelloLayerScene)
sceneClass = NSClassFromString([NSString stringWithFormat: @"%@Scene", layerClassName]);
if (sceneClass && [sceneClass isSubclassOfClass: CC3Scene.class]) return sceneClass;
CC3Assert(NO, @"%@ could not determine the appropriate class to instantiate to automatically populate the cc3Scene property.", self);
return nil;
}
问题解决了。
对于其他场景,我只是将它添加到openlayer部分