是否可以从GameCenter获取数据并为其创建自己的皮肤?
如果是,我在哪里可以访问我们收到的所有数据?我想要的重要数据是当前的比赛,其他一切对我来说都不是什么大问题。有人可以帮忙吗?!
答案 0 :(得分:1)
这些应该让你前进:
[GKTurnBasedMatch loadMatchesWithCompletionHandler:(void (^)(NSArray *matches, NSError *error))completionHandler];
[GKTurnBasedMatch loadMatchDataWithCompletionHandler:(void (^)(NSData *matchData, NSError *error))completionHandler];
编辑:
要一步一步解释整个过程需要很长的篇幅,但这是主要的想法:
[GKTurnBasedMatch loadMatchesWithCompletionHandler:(void (^)(NSArray *matches, NSError *error)){
for (GKTurnBasedMatch *myMatch in matches) {
// update your UI depending on the games. Below is just an example.. This part is up to you - update a tableView, manage a view etc..
int k = 0; // will hold the number of active players still in the game
for (GKTurnBasedParticipant *part in myMatch.participants) {
if(participant.matchOutcome != GKTurnBasedMatchOutcomeQuit){
k++;
}
}
if ([myMatch.currentParticipant.playerID isEqualToString [GKPlayer localPlayer].playerID]) {
//our turn
if (k<2) { //there are less than 2 active players - end game if it's your turn etc...
//end turn depending on your turn.
return;
}
//update your UI for that match..
} else { //not your turn
//update your UI - goes to their turn section for example
}
}
}];
我再次从头脑中写下了所有这些,所以我确定会有错误,但那是你想要的主要路线。您想获得当前比赛的列表 - 并根据轮到它或者游戏结束等列出它们。