添加声音时我在 sprite kit 中收到此错误的任何想法?

Any ideas why I'm getting this error in sprite kit when adding sound?

override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
    if (gameOver == 0) {
        //Player End Jump.
        player.physicsBody?.applyImpulse(CGVectorMake(0, -40))
        player.runAction(SKAction.playSoundFileNamed("sounds/jump.caf", waitForCompletion: false))
    }
}

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Resource sounds/jump.caf cannot be found in the main bundle' * First throw call stack:

我正在用智能手机发短信。希望这可以帮助。

let jumpSound = SKAction.playSoundFileNamed("jump.caf", waitForCompletion: true); self.runAction(jumpSound);

您的应用无法找到您的声音文件 sounds/jump.caf。您在哪里以及如何将它添加到您的 Xcode 项目中?

今晚我也遇到了同样的事情。在添加新声音时,我所有预先存在的声音都与它们的目标断开了连接。这导致了上面列出的崩溃。我必须 select 每个并重新选中目标框。

同时确保在添加新声音时选中相同的框。