如何在 tvOS 中打开游戏中心排行榜?我已将此代码用于我的 iPhone 游戏,“排行榜标识符”在 tvOS 上不可用。
我计划在 AppleTV 上使用相同的排行榜(这将是同一个游戏)。
非常感谢您的帮助,
斯特凡
@IBAction func handleGameCenter(sender: UIButton) {
let gcViewController = GKGameCenterViewController()
gcViewController.viewState = GKGameCenterViewControllerState.Leaderboards
gcViewController.leaderboardIdentifier = gamePrefix + "Leaderboard"
gcViewController.gameCenterDelegate = self
// Show leaderboard
self.presentViewController(gcViewController, animated: true, completion: nil)
}
func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController) {
gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
}
我也遇到了“没有可用数据”屏幕的问题,但最终解决了。这对我在 tvOS 上打开游戏中心排行榜很有用:
- 打开 Assets.xcassets(与您设置应用程序图标/启动屏幕的文件相同)
- 右键单击带有 appicon/launchsreen 的面板,然后选择 Game Center -> New Apple TV Leaderboard
- 为新排行榜添加图形
- 当在右侧面板的资产文件中选择排行榜时,找到标识符字段并将排行榜的标识符放在那里
-
使用此代码打开排行榜:
GKGameCenterViewController *gcViewController = [[GKGameCenterViewController alloc] init];
gcViewController.gameCenterDelegate = self;
[self presentViewController:gcViewController animated:YES completion:nil];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)