2015-10-18 79 views
1

現在我完成了我的遊戲製作,我需要添加的所有內容都是應用程序內購買和排行榜,並且不會弄亂任何東西,用測試應用程序做這個。我的排行榜現在正在顯示,儘管我在測試時登錄了遊戲中心(在真實設備和模擬器上),但在查看排行榜時我卻沒有得分。但是我的代碼很好,我已經經歷了幾天的蘋果文檔和其他教程。但所有的教程都過時了,並且蘋果文檔在某些特定的事情上很不清楚。但我認爲我的代碼是罰款:遊戲中心排行榜不工作(「沒有分數」)

let HighscoreDefault = NSUserDefaults.standardUserDefaults() 
    if (HighscoreDefault.valueForKey("highScore") != nil){ 

     highScore = HighscoreDefault.valueForKey("highScore") as! NSInteger 
    } 
    else { 

     highScore = 0 
    } 

    if (score > highScore){ 

     let HighscoreDefault = NSUserDefaults.standardUserDefaults() 
     HighscoreDefault.setValue(score, forKey: "highScore") 
     highScore = HighscoreDefault.valueForKey("highScore") as! NSInteger 
     saveScore(score) 
    } 

這就是我的得分節省遊戲方法,這就是如何我上傳到排行榜:

func saveScore(score: Int){ 
    let player = GKLocalPlayer() 
    if player.authenticated == true { 

     let scoreReporter = GKScore(leaderboardIdentifier: "testingleaderboard101") //leaderboard id here 

     scoreReporter.value = Int64(highScore) //score variable here (same as above) 

     let scoreArray: [GKScore] = [scoreReporter] 

     GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError?) -> Void in 
      if error != nil { 
       print("error") 
      } else { 
       print("reported correctly") 
      } 
     }) 

    } 
} 

我敢肯定錯誤不在這裏,但我發佈,以防萬一。

這裏就是我得到的記錄:

插件com.apple.GameCenterUI.GameCenterDashboardExtension使其無效

+0

如果我的代碼中確實存在錯誤,但我認爲遊戲中心的排行榜目前已破解/正在發生問題,因爲我擁有的所有其他遊戲(不是說我的,來自應用商店的)顯示完全相同的錯誤「未排名」,我的分數沒有顯示在排行榜上。 – Hades

回答

2

我固定它,在IOS 9一些bug導致GKLocalPlayer()認證返回假即使玩家在登錄所以在savescore功能,如果玩家被認證

3
let player = GKLocalPlayer() 

應該是不檢查:

let player = GKLocalPlayer.localPlayer() 

檢查iOS Developer Library的GKLocalPlayer類參考文檔中的「訪問共享本地播放器」部分。

我試圖把這個評論,但我沒有足夠的分數。具有必要特權的人請這樣做。

相關問題