I am using the following code to play music on my MENU SKScene:
Under the SKScene I declare the music action:
class MENU: SKScene {
let action: SKAction = SKAction.playSoundFileNamed("gameMusic.wav", waitForCompletion: false)
And in the touches began method, I play my sound when a button is touched.
self.runAction(action, withKey:"stopIce")
And under my didMoveToView: I have the following code to stop the music when the MENU scene loads.
self.removeActionForKey("stopIce")
When I touch the button on the MENU SkScene and transit to my Level Scene, the music plays perfectly. However, when I transition back to the MENU Skene where the button was, the code does not stop the music?
self.removeActionForKey("stopIce")
I want to stop all sounds when you go back to the MENU Scene so that if the player touches the button to go to Level SKScene again, the music does not have 2 tracks playing at the same time. Thanks :)