Swift:线程1:SpriteKit中的信号SIGABRT错误?
我一直在遵循一个教程,帮助我完成一个我一直在做的游戏,在我加入这个功能之前,一切都运行得很顺利:Swift:线程1:SpriteKit中的信号SIGABRT错误?,swift,sprite-kit,Swift,Sprite Kit,我一直在遵循一个教程,帮助我完成一个我一直在做的游戏,在我加入这个功能之前,一切都运行得很顺利: func generateCloud(seconds: NSTimeInterval) { let x = size.width / 2 * cloudWidth / 2 let y = CGFloat(arc4random_uniform(UInt32(size.height))) - size.height / 2 let cloud = MCTCloud(size:
func generateCloud(seconds: NSTimeInterval) {
let x = size.width / 2 * cloudWidth / 2
let y = CGFloat(arc4random_uniform(UInt32(size.height))) - size.height / 2
let cloud = MCTCloud(size: CGSizeMake(cloudWidth, cloudHeight))
cloud.position = CGPointMake(x, y)
addChild(cloud)
}
并在AppDelegate.swift中的绿色断点处发现一个错误,该断点表示线程1:SIGABRT,并进一步查看它以找到以下内容:
2015-08-31 20:46:54.051 Test Runs[19662:1306631] -[Test_Runs.MCTCloudGen generateCloud]: unrecognized selector sent to instance 0x7fe110c6d900
2015-08-31 20:46:54.055 Test Runs[19662:1306631] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Test_Runs.MCTCloudGen generateCloud]: unrecognized selector sent to instance 0x7fe110c6d900'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107a8dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001099eebb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107a950ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001079eb13c ___forwarding___ + 988
4 CoreFoundation 0x00000001079eacd8 _CF_forwarding_prep_0 + 120
5 Foundation 0x000000010810a744 __NSFireTimer + 83
6 CoreFoundation 0x00000001079f5174 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
7 CoreFoundation 0x00000001079f4d35 __CFRunLoopDoTimer + 1045
8 CoreFoundation 0x00000001079b6d3d __CFRunLoopRun + 1901
9 CoreFoundation 0x00000001079b6366 CFRunLoopRunSpecific + 470
10 GraphicsServices 0x000000010eed8a3e GSEventRunModal + 161
11 UIKit 0x00000001087228c0 UIApplicationMain + 1282
12 Test Runs 0x00000001078877b7 main + 135
13 libdyld.dylib 0x000000010a148145 start + 1
14 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
每次我运行游戏时,它都会崩溃,并将我带回AppDelegate文件中的断点。有点失落和沮丧。提前谢谢你的帮助
编辑
以下是MCTCloud类:
class MCTCloud: SKShapeNode {
init(size: CGSize) {
super.init()
let path = CGPathCreateWithEllipseInRect(CGRect(x: 0, y: 0, width: size.width, height: size.height), nil)
self.path = path
fillColor =
UIColor.whiteColor()
startMoving()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func startMoving() {
let moveLeft = SKAction.moveByX(-10, y: 0, duration: 1)
runAction(SKAction.repeatActionForever(moveLeft))
}
}
它来自您使用MCTCloud调用的方法。。。。。给我们看一个类MCTCloud:O我看不懂,把它编辑到你的帖子里,然后格式化它。plz:试着,给我一点时间。嗯。。。您是否在任何地方调用generateCloud方法?如果不是,您使用的是标准Xcode,没有插件/额外的第三方类,可能会影响您的代码,您使用的只是标准的Sprite工具包模板?我不这么认为……可能就是这样。我该怎么称呼这个?抱歉,有点新,是的,我使用的是标准模板。