Ethan Humphries Ethan Humphries - 17 days ago 7x
iOS Question

Stopping/Pausing a sound that is set to repeat forever in SpriteKit Swift 3

I'm having an issue and would really like it if someone could help out, basically I have a sequence of two sounds that are set to repeat forever. However, I want it so that I can trigger the sound to stop.

All I really need to know is:

In Swift 3 SpriteKit, what code do I use to stop, or pause, a repeating sequence of sounds indefinitely?


Always good practice to show some code on stack overflow, with your current question we can only take guesses.

Are you using SKActions for sound?. If you are you can give the repeat action a key and remove that action later.

 let repeatAction = SKAction.repeatActionForever(YOUSOUNDACTION)
 run(repeatAction, withKey: "key")

Than you can say

 removeAction(forKey: "key")

when you want to stop the repeat action.

Hope this helps