游戏中心功能全解析:排行榜、成就与匹配机制
1. 排行榜功能
在项目中,实现了向游戏中心提交和获取排行榜分数的功能。以下是具体的操作步骤和代码示例:
- 提交分数 :
在 TileMapLayer 类的 onPlayerInfoReceived 方法中提交一个虚拟分数到游戏中心的 Playtime 类别下。
-(void) onPlayerInfoReceived:(NSArray*)players
{
GameKitHelper* gkHelper = [GameKitHelper sharedGameKitHelper];
[gkHelper submitScore:1234 category:@"Playtime"];
}
submitScore 方法在 GameKitHelper 类中实现,代码如下:
-(void) submitScore:(int64_t)score category:(NSString*)category
{
if (isGameCenterAvailable == NO)
return;
GKScore* gkScore = [[GKScore alloc] initWithCategory:category];
gkScore.valu
超级会员免费看
订阅专栏 解锁全文
52

被折叠的 条评论
为什么被折叠?



