在SKScene中显示GKGameCenterViewController [英] show GKGameCenterViewController in SKScene

查看:72
本文介绍了在SKScene中显示GKGameCenterViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力解决以下问题:

I struggling with the following Problem:

我用SpriteKit制作了一个游戏.我在游戏中实现了 GameCenter .有用.玩家自动登录,高分将添加到默认的排行榜中.但是例如在"EndScreen"中,我想显示 GameCenterLeaderboard .

I've made a game with SpriteKit. I implemented the GameCenter to my game. It works. Player logs in automatically and the highscore will be added to the default Leaderboard. But for example in the "EndScreen" I want to show the GameCenterLeaderboard.

Appledocumentation告诉我,我应该使用以下代码:

Appledocumentation tells me that I should use the following code:

- (void) showGameCenter

{

GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];

if (gameCenterController != nil)

{

gameCenterController.gameCenterDelegate = self;

[self presentViewController: gameCenterController animated: YES completion:nil];

}

}

但是 presentViewController 不起作用.有什么方法可以从 SKScene 切换到我的标准 ViewController .或者我如何在触摸按钮的情况下显示 GameCenterleaderboard ?

But presentViewController does not work. Is there any way to switch from a SKScene to my standard ViewController. Or how can I show up the GameCenterleaderboard with a button touched?

说实话,我是编程新手,所以这里的问题对于您来说可能不是一个大问题.非常感谢您的帮助.

To be honest I'm pretty new to programming so this issue here might not a big problem to solve for you guys. Big big thanks for the help.

推荐答案

是的,有一种方法,您可以直接从-(void)showGameCenter 调用此代码:

yes there is a way, you can call this code directly from -(void)showGameCenter:

  UIViewController *vc = self.view.window.rootViewController;
  [vc presentViewController: gameCenterController animated:YES completion:Nil];

这篇关于在SKScene中显示GKGameCenterViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆