我一直在使用playSoundFileNamed()播放机关枪类型的声音-重复非常快,并且经常有声音重叠。我想给它添加一个音量控制,但我不知道怎么做--因为它需要不同数量的声音效果在彼此之间播放,我不得不当场创建音频播放器,但我找不到一种方法来预先加载它的声音数据,这使得它像疯了一样滞后。SKAction.playSoundFileNamed()运行得很好,但是...它没有音量选项。我还没有想出一种方法来复制它的音量,而不是滞后。
发布于 2017-08-08 05:22:02
首选的方法是使用SKAudioNode来达到你想要的效果。
但要回答手头的问题
let sound = SKAction.playSoundFileNamed("machinegun")
let action = SKAction.changeVolume(by: -1, duration: 1)
let group = SKAction.group([sound,action])
node.run(group)https://developer.apple.com/documentation/spritekit/skaction/1417664-playsoundfilenamed
https://stackoverflow.com/questions/45555568
复制相似问题