【发布时间】:2014-09-11 02:19:19
【问题描述】:
我正在苹果的 Xcode 6 GM 种子上使用 swift 创建游戏。我正在添加游戏中心排行榜,并想向排行榜报告分数。除了报告分数功能,我已经完成了所有设置。这是我的代码:
func reportScores() {
if GKLocalPlayer.localPlayer().authenticated == true{
var highScore = userDefaults.integerForKey("myHighScore")
var scoreReporter = GKScore(leaderboardIdentifier: "myLeaderboarID")
scoreReporter.value = Int64(highScore)
var scoreArray: [GKScore] = [scoreReporter]
GKScore.reportScores([scoreReporter], withCompletionHandler: nil) {
}
}
}
我尝试了这个,然后出现一个错误,说 reportScore 方法不能转换为 $T2。有人可以告诉我如何将我的分数发布到 Game Center 排行榜吗?谢谢!
【问题讨论】:
标签: ios xcode swift game-center