将成就发送到 GameCenter 问题!

发布于 2024-10-30 04:39:20 字数 1211 浏览 0 评论 0原文

好吧,我已经注册了排行榜和成就(仅用于测试目的)。我使用 GameCenterManager.h/.m 和 AppScoreValue.h

我的排行榜正常工作,接收所有分数,将它们按顺序排列,但成就不会授予玩家。

我想要一个显示如何报告成就的示例,我尝试了以下方法:

我的视图确实加载方法如下所示:

-(void)viewDidLoad{
   [GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
    if (error != nil)
    {
        NSLog(@"ACHIEVEMENTS WERE NOT LOADED");
    } else {
        NSLog(@"ACHIEVEMENTS WERE LOADED");
    }

    if (achievements != nil)
    {
        NSLog(@"THERE ARE ACHIVEMENTS");
    } else {
        NSLog(@"THERE ARE NO ACHIVEMENTS %@", achievements);
    }
}];

这是我的成就报告方法:

- (IBAction)reportAchievementIdentifier:(NSString*)identifier percentComplete:(float) percent {    
    GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
    if (achievement)
    {
        achievement.percentComplete = percent;
        [achievement reportAchievementWithCompletionHandler:^(NSError *error)
         {
             if (error != nil)
             {
                 // Retain the achievement object and try again later (not shown).
             }
         }];
    }

}

Well, I have already registered a leaderboard and an achievement (just for testing purposes). I use that GameCenterManager.h/.m and AppScoreValue.h

My leaderboard is working normally receives all the scores, puts them in order, but the achievement isn't granted to the player.

I'd like an example showing how to report achievements, I tried this:

My view did load method looks like this:

-(void)viewDidLoad{
   [GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
    if (error != nil)
    {
        NSLog(@"ACHIEVEMENTS WERE NOT LOADED");
    } else {
        NSLog(@"ACHIEVEMENTS WERE LOADED");
    }

    if (achievements != nil)
    {
        NSLog(@"THERE ARE ACHIVEMENTS");
    } else {
        NSLog(@"THERE ARE NO ACHIVEMENTS %@", achievements);
    }
}];

Here's my achievement reporting method:

- (IBAction)reportAchievementIdentifier:(NSString*)identifier percentComplete:(float) percent {    
    GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
    if (achievement)
    {
        achievement.percentComplete = percent;
        [achievement reportAchievementWithCompletionHandler:^(NSError *error)
         {
             if (error != nil)
             {
                 // Retain the achievement object and try again later (not shown).
             }
         }];
    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

森林迷了鹿 2024-11-06 04:39:20

当您报告成就时,您可以这样调用:(

[self reportAchievementIdentifier:@"com.yourapp.yourachievement" percentComplete:100.0];

您希望将标识符替换为您用于 Game Center 标识符的内容。)

我建议查看 此文档,来自 Apple。它包含有关如何在应用程序中使用成就的完整教程。

基本思想是您的应用程序报告用户完成成就的百分比。请注意,成就并不总是立即传播。

When you report an Achievement, you call something like this:

[self reportAchievementIdentifier:@"com.yourapp.yourachievement" percentComplete:100.0];

(You want to replace the identifier with whatever you used for your Game Center identifier.)

I suggest looking at this documentation from Apple. It contains a full fledged tutorial on how to use Achievements in your app.

The basic idea is that your app reports a a percentage of how much your user completed the achievement. Note that achievements don't always propagate immediately.

绝不放开 2024-11-06 04:39:20
GKAchievement *achievement = 
    [[GKAchievement alloc] initWithIdentifier: identifier];
achievement.showsCompletionBanner = YES;

就是这样!

GKAchievement *achievement = 
    [[GKAchievement alloc] initWithIdentifier: identifier];
achievement.showsCompletionBanner = YES;

that's it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文