Is there a way to regulate the volume of sound played via SKAction playSoundFileNamed:waitForCompletion:.
I would like to implement a simple music & sound effects sl
Since iOS 9.0 you can change the volume to your node running another action if you have already runned your audio (remember that this one obviusly cannot work if you have something that run with repeatForever
):
let changeVolumeAction = SKAction.changeVolume(to: 0.3, duration: 0.3)
node.run(changeVolume)
Or you can create a group and launching your audio with the correct volume:
let effectAudioAction = SKAction.playSoundFileNamed("electricshockLow.mp3", waitForCompletion: false)
let changeVolumeAction = SKAction.changeVolume(to: 0.3, duration: 0.3)
let effectAudioGroup = SKAction.group([effectAudioAction,changeVolumeAction])
node.run(effectAudioGroup)