我已通过以下方式将Game Center集成到我的应用中:
加载游戏时
func saveHighscore(_ number : Int){
if GKLocalPlayer.localPlayer().isAuthenticated {
let scoreReporter = GKScore(leaderboardIdentifier: "...")
scoreReporter.value = Int64(number)
let scoreArray : [GKScore] = [scoreReporter]
GKScore.report(scoreArray, withCompletionHandler: nil)
}
}
func showLeaderboard() {
let gameCenter = GKGameCenterViewController()
gameCenter.gameCenterDelegate = self
gameCenter.viewState = GKGameCenterViewControllerState.leaderboards
if let gameViewController = self.view?.window?.rootViewController {
gameViewController.show(gameCenter, sender: self)
gameViewController.navigationController?.pushViewController(gameCenter, animated: true)
}
}
然后在gameOver场景中:
count(fieldName)
某些设备无法找到排行榜,其他设备可以找到它,但只能显示其得分等。 我错过了什么吗? 认证工作正常。