さて、私はcocos2dゲーム内から呼び出されたAppleGameCenterリーダーボードを表示しようとしています。
私はそうするのにいくつかの問題がありました。
私は最終的にこれに遭遇し、CCSceneクラスの1つに次のように実装しました(コンパイラの警告を防ぐために元のコードを少し変更しました)。
- (void)showLeaderboardForCategory:(NSString *)category
{
// Create leaderboard view with default Game Center style
leaderboardController = [[GKLeaderboardViewController alloc] init];
// If view controller was successfully created...
if (leaderboardController != nil)
{
// Leaderboard config
leaderboardController.leaderboardDelegate = self; // leaderboardController will send messages to this object
leaderboardController.category = category;
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime;
// Create an additional UIViewController to attach the GKLeaderboardViewController to
vc = [[UIViewController alloc] init];
// Add the temporary UIViewController to the main view
[[CCDirector sharedDirector].view.window addSubview:vc.view];
// Tell UIViewController to present the leaderboard
[vc presentModalViewController:leaderboardController animated:YES];
}
}
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[vc dismissViewControllerAnimated:YES completion:nil];
}
そして、それは動作します!少なくとも私がそれを呼ぶとき、それはリーダーボードを正しく表示します。
唯一の問題は、リーダーボードで[完了]をタップしてモーダルビューが閉じたときに、CCSceneがタップイベントに応答しなくなることです。
応答性を取り戻すには何をする必要がありますか?