首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从OpenFeint获得高分?

如何从OpenFeint获得高分?
EN

Stack Overflow用户
提问于 2010-08-28 07:30:21
回答 1查看 2.1K关注 0票数 1

在他们的支持下,OpenFeint给了你这个,但我不太明白。我如何获取排行榜数据,比如前10名,并在我自己的UI中显示它?

原始链接:http://www.openfeint.com/ofdeveloper/index.php/kb/article/000028

代码语言:javascript
复制
[OFHighScoreService getPage:1 forLeaderboard:@"leaderboard_id_string" friendsOnly:NO silently:YES onSuccess:OFDelegate(self, @selector(_scoresDownloaded:)) onFailure:OFDelegate(self, @selector(_failedDownloadingScores))];

- (void)_scoresDownloaded:(OFPaginatedSeries*)page
{
    NSMutableArray* highscores = nil;

    if ([page count] > 0)
    {
        if ([[page objectAtIndex:0] isKindOfClass:[OFTableSectionDescription class]])
        {
            // NOTE: In the following line, we access "[page objectAtIndex:1]" to retrieve high scores from
            // the global leaderboard.  Using "[page objectAtIndex:0]" would retrieve scores just for the local player.
            // Older versions of OpenFeint did not break this out into 2 sections.
            highscores = [(OFTableSectionDescription*)[page objectAtIndex:1] page].objects;
        }
        else
        {
            highscores = page.objects;
        }
    }

    for (OFHighScore* score in highscores)
    {
        // ...
    }
}
- (BOOL)canReceiveCallbacksNow
{
    return YES;
} 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-08-28 07:41:18

请求高分页面的代码是第一行,即:

代码语言:javascript
复制
[OFHighScoreService getPage:1 forLeaderboard:@"leaderboard_id_string" friendsOnly:NO silently:YES onSuccess:OFDelegate(self, @selector(_scoresDownloaded:)) onFailure:OFDelegate(self, @selector(_failedDownloadingScores))];

将此行放在想要开始查询高分的位置。您可以根据需要更改页码。一旦检索到高分页面,就会调用回调_scoresDownloaded。该示例展示了如何遍历highscores数组中的OFHighScore对象。您可以用自己的代码替换注释// ...,以便向玩家显示比分或其他内容。

(如果出现错误,则调用_failedDownloadingScores;您应该实现它以显示错误。)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3588762

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档