致命异常:NSInvalidArgumentException无法加载资源jump.caf(iOS)

时间:2015-08-17 10:14:51

标签: ios xcode swift ios8 sprite-kit

我从我的iOS应用程序的crashlytics获取这些崩溃报告。有时会发生崩溃,但并不总是如此,因此难以重现。

    Thread : Fatal Exception: NSInvalidArgumentException
    0  CoreFoundation                 0x2b57d137 __exceptionPreprocess
    1  libobjc.A.dylib                0x398d3c77 objc_exception_throw
    2  CoreFoundation                 0x2b57d07d -[NSException initWithCoder:]
    3  SpriteKit                      0x2eaadc6f +[SKPlaySound playSoundFileNamed:atPosition:waitForCompletion:]
    4  SpriteKit                      0x2ea47f17 +[SKAction(SKActions) playSoundFileNamed:waitForCompletion:]
    5  my_project                     0x00150ef0 function signature specialization  of my_project.GameScene.CreateScene (my_project.GameScene)() -> () (GameScene.swift:125)
    6  my_project                     0x00142a10 my_project.GameScene.CreateScene (my_project.GameScene)() -> () (GameScene.swift)
    7  my_project                     0x00150e24 function signature specialization  of my_project.GameScene.init (my_project.GameScene.Type)(size : C.CGSize) -> my_project.GameScene (GameScene.swift:120)
    8  my_project                     0x00182b30 function signature specialization  of my_project.GameViewController.viewDidLoad (my_project.GameViewController)() -> () (GameViewController.swift:48)
    9  my_project                     0x0017ec78 @objc my_project.GameViewController.viewDidLoad (my_project.GameViewController)() -> () (GameViewController.swift)
    10 UIKit                          0x2ebdd74d -[UIViewController loadViewIfRequired]
    11 UIKit                          0x2ebdd4bd -[UIViewController view]
    12 UIKit                          0x2ebe35e7 -[UIWindow addRootViewControllerViewIfPossible]
    13 UIKit                          0x2ebe0f5f -[UIWindow _setHidden:forced:]
    14 UIKit                          0x2ec4c081 -[UIWindow makeKeyAndVisible]
    15 UIKit                          0x2ee3f507 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:]
    16 UIKit                          0x2ee41acf -[UIApplication _runWithMainScene:transitionContext:completion:]
    17 UIKit                          0x2ee4c7a9 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke
    18 UIKit                          0x2ee40287 -[UIApplication workspaceDidEndTransaction:]
    19 FrontBoardServices             0x32028ec1 __31-[FBSSerialQueue performAsync:]_block_invoke_2
    20 CoreFoundation                 0x2b543255 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
    21 CoreFoundation                 0x2b542519 __CFRunLoopDoBlocks
    22 CoreFoundation                 0x2b541073 __CFRunLoopRun
    23 CoreFoundation                 0x2b48c9a1 CFRunLoopRunSpecific
    24 CoreFoundation                 0x2b48c7b3 CFRunLoopRunInMode
    25 UIKit                          0x2ec42a57 -[UIApplication _run]
    26 UIKit                          0x2ec3d635 UIApplicationMain
    27 my_project                     0x00187db8 main (AppDelegate.swift:14)
    28 libdyld.dylib                  0x39ea1aaf start.my_project

以下是我如何使用SKAction加载和播放声音的代码

var jump_Sound:SKAction?
func jumpSound(){
        self.runAction(jump_Sound)
//        runAction(SKAction.playSoundFileNamed("jump.mp3", waitForCompletion: false))
    }

override init(size: CGSize) {
        super.init(size: size)
        self.CreateScene()
}

func CreateScene(){
    jump_Sound = SKAction.playSoundFileNamed("jump.caf", waitForCompletion: false)
}

目前游戏在CreateScene函数崩溃,我正在加载jump_sound。如果有更好的方法在SpriteKit项目中播放声音效果,请建议我。

0 个答案:

没有答案