gpt4 book ai didi

ios - SpriteKit 中的游戏中心不关闭排行榜

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:09:14 24 4
gpt4 key购买 nike

在这里经过大量搜索后,我终于找到了一种让 Game Center 在 SpriteKit 中显示的方法,但现在我无法调用 leaderboardViewControllerDidFinish 方法。我在不同的应用程序中使用此代码并且它工作正常但由于某些原因为 SpriteKit 修改了代码它只是不工作。提前致谢!

这是我的代码示例:

- (void)showGameCenterButtonPressed:(id)sender {
{
if ([GKLocalPlayer localPlayer].authenticated == NO) {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"You must enable Game Center!"
message:@"Sign in through the Game Center app to enable all features"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
} else {
GKGameCenterViewController *leaderboardViewController = [[GKGameCenterViewController alloc] init];
if (leaderboardViewController != NULL)
{

UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: leaderboardViewController animated: YES completion:nil];
}
}

}

- (void)leaderboardViewControllerDidFinish:(GKGameCenterViewController *)viewController {
NSLog(@"in leaderboardControllerDidFinish");
UIViewController *vc = self.view.window.rootViewController;
[vc dismissViewControllerAnimated:YES completion:nil];

}

最佳答案

回答我自己的问题...我只是直接从 Apple 获取代码

- (void)showGameCenterButtonPressed:(id)sender {
{
if ([GKLocalPlayer localPlayer].authenticated == NO) {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"You must enable Game Center!"
message:@"Sign in through the Game Center app to enable all features"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
} else {
GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
if (gameCenterController != nil)
{
gameCenterController.gameCenterDelegate = self;
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: gameCenterController animated: YES completion:nil];
}
}
}

- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController*)gameCenterViewController {

UIViewController *vc = self.view.window.rootViewController;
[vc dismissViewControllerAnimated:YES completion:nil];

关于ios - SpriteKit 中的游戏中心不关闭排行榜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20308044/

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