Game Center Not Properly Working. Swift, Sprite Kit -


i tried add game center sprite kit game, it's not working properly.

when game starts in simulator, game center login page show up. when start game on phone not. can tell me doing wrong.

//gameviewcontroller.swift import gamekit  class gameviewcontroller: uiviewcontroller, adbannerviewdelegate, gkgamecentercontrollerdelegate {  var bannerview:adbannerview?  override func viewdidload() {     super.viewdidload()      // presenting scene without using gamescene.sks     let skview = view as! skview     let myscene = gamescene(size: skview.frame.size)     myscene.scalemode = .resizefill      skview.presentscene(myscene)     authenticatelocalplayer()  }  //initiate gamecenter func authenticatelocalplayer(){      var localplayer = gklocalplayer.localplayer()      localplayer.authenticatehandler = {(viewcontroller, error) -> void in          if (viewcontroller != nil) {             self.presentviewcontroller(viewcontroller, animated: true, completion: nil)         }          else {             println((gklocalplayer.localplayer().authenticated))         }     }  }  func gamecenterviewcontrollerdidfinish(gamecenterviewcontroller: gkgamecenterviewcontroller!) {     gamecenterviewcontroller.dismissviewcontrolleranimated(true, completion: nil) }    //gamescene.swift import gamekit  class gamescene: skscene, skphysicscontactdelegate{ var playerscore = 0 func playerscoreupdate() {     playerscorelabel.text = "\(playerscore)" }  func savehighscore(high:int) {     nsuserdefaults.standarduserdefaults().setinteger(high, forkey: "highscore")     //check if user signed in     if gklocalplayer.localplayer().authenticated {          var scorereporter = gkscore(leaderboardidentifier: "tf1g002id") //leaderboard id here          scorereporter.value = int64(playerscore) //score variable here (same above)          var scorearray: [gkscore] = [scorereporter]          gkscore.reportscores(scorearray, withcompletionhandler: {(error : nserror!) -> void in             if error != nil {                 println("error")             }         })      } }    //gameover.swift import gamekit  class gameoverscene: skscene, gkgamecentercontrollerdelegate {  //shows leaderboard screen func showleader() {     var vc = self.view?.window?.rootviewcontroller     var gc = gkgamecenterviewcontroller()     gc.gamecenterdelegate = self     vc?.presentviewcontroller(gc, animated: true, completion: nil) }  // press finger override func touchesbegan(touches: set<nsobject>, withevent event: uievent) {     touch: anyobject in touches {         let location = touch.locationinnode(self)         let node = self.nodeatpoint(location)          if node.name == "replay" {             playsound(sound)         }          if node.name == "leaderboard" {             showleader()         }      } }  //hides leaderboard screen func gamecenterviewcontrollerdidfinish(gamecenterviewcontroller: gkgamecenterviewcontroller!) {     gamecenterviewcontroller.dismissviewcontrolleranimated(true, completion: nil)  } 

did import gamekit framework app? go project -> general -> scroll until see linked frameworks -> click plus sign -> add gamekit framework searching

enter image description here


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -