【发布时间】:2018-07-09 14:48:57
【问题描述】:
我有一个手势识别器的以下代码,它会在被点击时播放喇叭,并在释放时停止:
@objc func didPressHorn(_ sender: UILongPressGestureRecognizer) {
let tapLocation = sender.location(in: sceneView)
if sender.state == .began {
if (wasNodeTapped(node: hornNode!, tapLocation: tapLocation)) {
hornNode!.runAction(SCNAction.playAudio(hornSound, waitForCompletion: false), forKey: "Horn")
hornPlaying = true
}
} else if sender.state == .ended {
if hornPlaying {
// tried all the possible solutions, but the sound won't stop
hornNode?.removeAction(forKey: "Horn")
hornNode?.removeAllActions()
hornNode?.isPaused = true
hornSound.volume = 0
hornPlaying = false
print("Horn off") //gets printed!
}
}
}
如您所见,我正在尝试所有可能的解决方案(我知道),并且打印语句也被打印出来。但是,声音不会关闭。你有什么想法,为什么?
【问题讨论】:
标签: ios objective-c swift scenekit arkit