Game Center 文档表明
playersToInvite
当您的应用程序直接从 Game Center 应用程序启动以托管比赛时,参数不为零。
一些人问这究竟是如何工作的,即似乎没有办法从 Game Center 应用程序中选择朋友并邀请他们从Game Center 玩;仅当您在游戏中邀请时才有效。此文档是否已过时,或者是否有从 Game Center 开始特定游戏比赛的秘密方法?我想测试一下inviteHandler
,但我无法确定如何将此参数传递给应用程序。
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)
{
// clean up games in progress here
if (acceptedInvite)
{
NSLog(@"acceptedInvite %@", acceptedInvite);
// The acceptedInvite parameter is non-nil when the application receives an
// invitation directly from another player.
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
mmvc.matchmakerDelegate = self;
[self disableHomeUI];
[self presentModalViewController:mmvc animated:YES];
}
else if (playersToInvite)
{
NSLog(@"playersToInvite %@", playersToInvite);
// playersToInvite parameter is non-nil when your application is launched
// directly from the Game Center application to host a match
[self disableHomeUI];
[self doPresentMatchMakerUIWithPlayersToInvite:playersToInvite];
}
};