重启游戏后按下某个按钮后,我的游戏不断崩溃。
在我正在运行游戏的ViewController中,动画总是在游戏中运行。
这是崩溃日志。有没有办法检测这次崩溃与我的动画有什么关系?
2014-08-05 00:21:30.044 windmill[702:90b] -[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10
2014-08-05 00:21:30.053 windmill[702:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10'
*** First throw call stack:
(
0 CoreFoundation 0x01c501e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x019cf8e5 objc_exception_throw + 44
2 CoreFoundation 0x01ced243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01c4050b ___forwarding___ + 1019
4 CoreFoundation 0x01c400ee _CF_forwarding_prep_0 + 14
5 QuartzCore 0x0013b9b8 CAObject_setValueForKeyPath_ + 2435
6 QuartzCore 0x0012129b -[CALayer setValue:forKeyPath:] + 471
7 QuartzCore 0x00105d51 -[CABasicAnimation applyForTime:presentationObject:modelObject:] + 1178
8 QuartzCore 0x0012415c _ZN2CA5Layer18presentation_layerEPNS_11TransactionE + 494
9 QuartzCore 0x00127cbe -[CALayer presentationLayer] + 43
10 UIKit 0x006eb0f1 _UIViewEatsTouches + 142
11 UIKit 0x006eb250 -[UIView(Geometry) hitTest:withEvent:] + 114
12 UIKit 0x006eb4f4 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke + 132
13 CoreFoundation 0x01cccd86 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
14 CoreFoundation 0x01cccc5f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
15 UIKit 0x006eb35c -[UIView(Geometry) hitTest:withEvent:] + 382
16 UIKit 0x006eb4f4 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke + 132
17 CoreFoundation 0x01cccd86 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
18 CoreFoundation 0x01cccc5f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
19 UIKit 0x006eb35c -[UIView(Geometry) hitTest:withEvent:] + 382
20 UIKit 0x006daeb1 __54+[UIWindow _hitTestToPoint:pathIndex:forEvent:screen:]_block_invoke + 175
21 UIKit 0x006dad1e +[UIWindow _topVisibleWindowPassingTest:] + 198
22 UIKit 0x006dadfa +[UIWindow _hitTestToPoint:pathIndex:forEvent:screen:] + 176
23 UIKit 0x0068c5bb _UIApplicationHandleEventQueue + 7975
24 CoreFoundation 0x01bd977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x01bd910b __CFRunLoopDoSources0 + 235
26 CoreFoundation 0x01bf61ae __CFRunLoopRun + 910
27 CoreFoundation 0x01bf59d3 CFRunLoopRunSpecific + 467
28 CoreFoundation 0x01bf57eb CFRunLoopRunInMode + 123
29 GraphicsServices 0x0341c5ee GSEventRunModal + 192
30 GraphicsServices 0x0341c42b GSEventRun + 104
31 UIKit 0x0068ff9b UIApplicationMain + 1225
32 windmill 0x00004afd main + 141
33 libdyld.dylib 0x03103725 start + 0
34 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
当我按下视图中的按钮时,应用程序崩溃了。这是动画代码:
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 4;
fullRotation.repeatCount= 1000;
[[stick layer] addAnimation:fullRotation forKey:@"60"];}
如果代码搞砸了,我很抱歉,我还在学习和构建小型应用和游戏以获得更好的练习。感谢。
答案 0 :(得分:0)
你应该删除带有fullRotation.fromValue的行,因为它不应该为自己分配CALayer。
fullRotation.fromValue = self.view.layer.presentationLayer;