0

是否可以从 GameCenter 获取数据并为其创建自己的皮肤?

如果是这样,我在哪里可以访问我们收到的所有数据?我想要的重要数据是当前比赛,其他一切对我来说都没什么大不了的。谁能帮忙?!

4

1 回答 1

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

}

}


}];

再次,我只是从头顶写下所有这些,所以我确定有错误,但这是你想要采取的主要路线。您想获取当前比赛的列表 - 并根据轮到谁或比赛是否结束以及其他内容列出它们。

于 2012-06-01T21:08:08.157 回答