一段时间以来,我一直在尝试在 SKScene 上显示游戏中心排行榜,但我无法弄清楚我已经查看了多篇文章.. 来自谷歌和这里,当我点击将您带到这里的按钮时场景它把你带到那里并显示一个灰屏,就是这样,我已经验证了播放器和所有内容。视图是否可能在幕后?这是我正在使用的场景
#import "DMLeaderBoard.h"
#import "DMGameKitHelper.h"
@implementation DMLeaderBoard
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
[self showLeaderboard];
}
return self;
}
-(void)showLeaderboard {
GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init];
if (leaderboardController != NULL)
{
leaderboardController.leaderboardIdentifier = @"1";
leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards;
leaderboardController.gameCenterDelegate = self;
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: leaderboardController animated: YES completion:nil];
}
}
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)viewController
{
UIViewController *vc = self.view.window.rootViewController;
[vc dismissViewControllerAnimated:YES completion:nil];
}
@end