iphone - 游戏中心细节

标签 iphone ios cocos2d-iphone

我想知道是否有人可以为我阐明 GameCenter。我正在构建我的第一个多人游戏应用程序,想知道我是否能够获取数据并使用它创建我自己的界面...

基本上我想使用我自己的 UI 来显示当前正在玩的游戏,如果你正在等待轮到你,或者是否轮到你等等,以及游戏的其他一些细节。这可能吗?或者我们只能通过 GameCenter UI 访问当前游戏吗?

此外,如果我能够对其进行换肤,或者至少自己获取数据并为其换肤.. 是否可以使用尽可能少的 GameCenter UI 围绕 GameCenter 构建应用程序?我基本上只是希望用户被封闭在我的游戏环境中,而不是每隔几次点击就被扔进 GameCenter。有道理吗?

感谢任何见解!非常感谢!

最佳答案

你可以做到这一点。该方法是获取显示正在进行的游戏的 UITableView 所需的所有数据。要在这里显示完全自定义的基于回合的 gamecenter View 的代码会很长。如果您查看为表格截取的代码,您可能会对这个概念有所了解:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MatchCell" owner:self options:nil];
        cell = [topLevelObjects objectAtIndex:0];
    }

    GKTurnBasedMatch *match = [[allMyMatches objectAtIndex:indexPath.section ] objectAtIndex:indexPath.row];
    MatchCell *c = (MatchCell *)cell;
    c.match = match;
    c.delegate = self;
    if ([match.matchData length] > 0) {
        NSString *storyString = [NSString stringWithUTF8String:[match.matchData bytes]];
        c.storyText.text = storyString;
        int days = -floor([match.creationDate timeIntervalSinceNow] / (60 * 60 * 24));
        c.statusLabel.text = [NSString stringWithFormat:@"Story started %d days ago and is about %d words", days, [storyString length] / 5];
    }

    if (indexPath.section == 2) {
        [c.quitButton setTitle:@"Remove" forState:UIControlStateNormal];
        [c.quitButton setTitle:@"Remove" forState:UIControlStateNormal];
    }

    return cell;
}

有关该主题的完整教程位于 Ray Wenderlich 教程团队的教程 iOS 5 中。如果你觉得慷慨,那就去吧,点击这个链接:http://www.raywenderlich.com/store/ios-5-by-tutorials This is what you get

关于iphone - 游戏中心细节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10440124/

相关文章:

ios - 检测应用程序是否链接到CoreLocation框架

ios - 创建游戏重播时的计时问题(赛车幽灵)

iphone - cocos2d 从 future 的特定时间开始粒子

iphone - 加载新 View

iphone - UITableView 和字母顺序

iphone - UIActionSheet 进行多个 UIButton 更改

ios - 在后台线程中绘制UITablveViewCell,可能吗?

ios - 方向改变后检测 UIView 的旋转宽度/高度

ios - 使用 Cocos2D 中数组中的 Sprite 进行碰撞检测

iphone - 我如何使用 CoreGraphics 绘制半圆