我正在使用 aSKAudioNode()
在我的游戏中播放背景音乐。我有播放/暂停功能,在插入耳机之前一切正常。根本没有声音,当我调用暂停/播放功能时出现此错误
AVAudioPlayerNode.mm:333:开始:所需条件为假:_engine->IsRunning() com.apple.coreaudio.avfaudio',原因:'所需条件为假:_engine->IsRunning()
有谁知道这意味着什么?
代码:
import SpriteKit
class GameScene: SKScene {
let loop = SKAudioNode(fileNamed: "gameloop.mp3")
let play = SKAction.play()
let pause = SKAction.pause()
var isPlaying = Bool()
override func didMoveToView(view: SKView) {
loop.runAction(play)
isPlaying = true
self.addChild(loop)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
_ = touches.first as UITouch!
for _ in touches {
if isPlaying {
loop.runAction(pause)
isPlaying = false
} else {
loop.runAction(play)
isPlaying = true
}
}
}
}