gpt4 book ai didi

ios - cocos2d 屏幕上没有添加排行榜

转载 作者:行者123 更新时间:2023-12-02 08:07:20 24 4
gpt4 key购买 nike

我使用下面的代码来显示排行榜,但我得到的只是控制台

cocos2d: surface size: 480x320

代码:

- (void)showLeaderboardForCategory:(NSString *)category
{
// Only execute if OS supports Game Center & player is logged in
if (hasGameCenter)
{

// Create leaderboard view w/ default Game Center style
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];

// If view controller was successfully created...
if (leaderboardController != nil)
{
// Leaderboard config
leaderboardController.leaderboardDelegate = self; // The leaderboard view controller will send messages to this object
leaderboardController.category = category; // Set category here
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime; // GKLeaderboardTimeScopeToday, GKLeaderboardTimeScopeWeek, GKLeaderboardTimeScopeAllTime

// Create an additional UIViewController to attach the GKLeaderboardViewController to
myViewController = [[UIViewController alloc] init];

// Add the temporary UIViewController to the main OpenGL view
[[[CCDirector sharedDirector] openGLView] addSubview:myViewController.view];

// Tell UIViewController to present the leaderboard
[myViewController presentModalViewController:leaderboardController animated:YES];
}
}
}

最后我这样调用代码:

    [[GameCenterManager sharedGameCenterManager] showLeaderboardForCategory:@"LeaderBoard"];

最佳答案

我找到了我必须写的解决方案:

    [[[[CCDirector sharedDirector] openGLView] window] addSubview:myViewController.view];

而不是:

    [[[CCDirector sharedDirector] openGLView] addSubview:myViewController.view];

关于ios - cocos2d 屏幕上没有添加排行榜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6724844/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com