swift - How to keep sound off while transitioning between SKScenes -


i created game in sprite kit , give user ability mute sound pressing button before can tap , start game. however, when game on , gameoverscene appears, music still stays muted. when new gamescene called music start playing again. know how solve issue. code have music.

var backgroundmusicplayer: avaudioplayer!  func playbackgroundmusic(filename: string) { let url = nsbundle.mainbundle().urlforresource(     filename, withextension: nil) if (url == nil) {     println("could not find file: \(filename)")     return }  var error: nserror? = nil backgroundmusicplayer =     avaudioplayer(contentsofurl: url, error: &error) if backgroundmusicplayer == nil {     println("could not create audio player: \(error!)")     return }  backgroundmusicplayer.numberofloops = -1 backgroundmusicplayer.preparetoplay() backgroundmusicplayer.play() }    override func didmovetoview(view: skview) {      mutesound.name = "mutesound"     mutesound.position.x = view.center.x     mutesound.position.y = view.center.y + 100     self.addchild(mutesound)      playbackgroundmusic("box office.mp3")  }   override func touchesbegan(touches: nsset, withevent event: uievent) {     touch: anyobject in touches {         let location = touch.locationinnode(self)         let node = self.nodeatpoint(location)          if node.name == "mutesound" {             backgroundmusicplayer.stop()         } } 


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -