【问题标题】:Cannot get the 3D Audio effect for skAudioNode in SpriteKit无法在 SpriteKit 中获取 skAudioNode 的 3D 音频效果
【发布时间】:2015-10-20 08:40:25
【问题描述】:

我正在试用 WWDC 2015 中宣布的新 skAudioNode。我是 swift 和 spriteKit 的新手。

首先在 sks 编辑器中,我将一个 Audio 对象拖到场景中,并命名为 audioNodeRed,它附加到一个视觉上为红色的 sprikit 节点。我在编辑器中指定了指向此节点的 wav 文件链接。

在 GameScene.swift 中,我写道:

let redNode:SKAudioNode = childNodeWithName("//audioNodeRed") as! SKAudioNode;
let actionPlaySound = SKAction.play()
redNode.runAction(actionPlaySound)

最后一行将崩溃并报错:terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: _engine->IsRunning()'

我通过指定一个 wav 文件来修复它以通过代码操作(xcode 错误?)

let actionPlaySound =SKAction.playSoundFileNamed("Crackling_Fireplace.wav", waitForCompletion: false)

好的,现在我可以听到声音了,但是如果我移动节点没有 3d 音效,我已经指定了场景的听者位置(仍在 GameScene.swift 中):

//sprite is a skSpriteNode in the center of the screen
self.listener = sprite

另一件事是我无法访问 Apple documentation 中指定的 avaudioengine 属性。例如

  redAudioNode.avAudioNode //SKAudioNode does not have a member named "avAudioNode"
  myScene.audioEngine   //SKScene does not have a member named "audioEngine"

我正在使用 XCode 7 beta version4。我想知道我在这里做错了什么,或者原因是 ios9 框架仍处于测试阶段。感谢您的帮助。

-------------添加----

好的,我通过进入后台并再次返回应用获得了 3d 音频效果。

【问题讨论】:

    标签: ios swift sprite-kit skspritenode ios9


    【解决方案1】:

    好的,我自己解决了问题,显然sks编辑器有问题。

    如果我在代码中而不是在编辑器中执行此操作,我会听到 3D 音效。

     audioNodeRed.positional = true
     audioNodeRed.autoplayLooped = true
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-16
      • 1970-01-01
      • 1970-01-01
      • 2014-10-24
      • 1970-01-01
      • 2012-04-19
      • 2014-11-03
      相关资源
      最近更新 更多