uiviewcontroller - Swift - Make segue from SKScene to Viewcontroller (game crash after getting out and then in to game) -


ok.. have problem, , cant figure out doing wrong, hope can med! have made game, , works should, can play, quit , restart. when score enough points, viewcontroller here @ medal. problem comes, when user goes game again after picking medal. game wont show game-scene.

i use notificationcenter in gameviewcontroller, make segue gamescene. , try in ways remove scene viewcontroller, because think problem lies there. nothing seems work :(

in gameviewcontroller have:

 notificationcenter.default.addobserver(self, selector: #selector(gameviewcontroller.doasegue), name: nsnotification.name(rawvalue: "doasegue"), object: nil)     func doasegue(){         let skview = self.view as! skview         skview.presentscene(nil)         self.dismiss(animated: false, completion: nil)         print(self.view)         self.performsegue(withidentifier: "gametooffer", sender: self)     } 

and when player dies use code in skscene, before make segue:

 if won {               self.removeallactions()             self.removeallchildren()             won = false             makesegue()         }  func makesegue() { notificationcenter.default.post(name: nsnotification.name(rawvalue: "doasegue"), object: nil) } 

i have no idea doing wrong. said, games restarts fine, dont think have forgot reset anything. reason cant in, once getting out of game. hope can me!


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -