关于 PlayersToInvite 用途的明确答案
游戏中心文档表明
playersToInvite
参数非零 当你的应用程序启动时 直接从游戏中心 申请主办一场比赛。
有些人问这到底是如何工作的,即似乎没有办法从 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];
}
};
The Game Center documentation indicates that the
playersToInvite
parameter is non-nil
when your application is launched
directly from the Game Center
application to host a match.
A few people have asked how this works exactly, i.e. there doesn't appear to be a way to select a friend from the Game Center application and invite them to play from Game Center; it only works when you invite in-game. Is this documentation dated or is there a secret way to start a game-specific match from Game Center? I'd like to test my inviteHandler
but I've been unable to determine how this parameter is passed to the application.
[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];
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为这些文档并没有反映当前的情况。据我所知,游戏中心应用程序目前甚至没有提供邀请朋友玩的界面。
另外,请检查开发者论坛(显然您有;))。库比蒂诺的某人似乎认为这是不可能的。所以...
I think the docs do not reflect the current state of affairs. As far as I can tell, the Game Center App does not even offer an interface for inviting friends to play, currently.
Also, check the developer forums (apparently you have ;) ). Someone from Cupertino seems to think it is not possible. So...
将我的应用程序 Cee-lo 投入生产后,
playersToInvite
代码变得活跃。这似乎是因为游戏中心应用程序本身的沙盒版本不允许您从那里与玩家开始游戏,但生产版本可以。如果你问我的话,这不是一个很好的测试环境!After launching my application Cee-lo into production, the
playersToInvite
code became active. This seems to be because the Sandbox version of the Game Center app itself does not allow you to start a game with a player from there, but the production version does. Not a very good test environment if you ask me!现在有一种方法可以使用 Game Center 应用来邀请 Game Center 好友。 上调用 registerListener: 时才有效
仅当您的游戏在 localPlayer GKPlayer: Game Center 应用程序
->游戏选项卡
->你的游戏
->球员部分
->选择一名球员
-> “玩游戏”
这将向其他玩家发送推送通知邀请。游戏不必必须在任一设备上运行。从iOS7开始。
此流程也有效:
游戏中心应用程序
->朋友选项卡
->点击好友
->点击一个共同的游戏(你的游戏)
->点击右上角的“...”
->点击“播放”
There is now a way to use the Game Center app to invite a Game Center friend. It ONLY works if your game calls registerListener: on the localPlayer GKPlayer:
Game Center App
-> games tab
-> your game
-> Players section
-> select a player
-> "Play a Game"
This will send a push notification invite to the other player. Game does not have to be running on either device. As of iOS7.
This flow also works:
Game Center App
-> friends tab
-> tap a friend
-> tap a game in common (your game)
-> tap the "..." in the top right corner
-> tap "Play"
我可能是错的,但我认为这只是“模拟器”,不能邀请特定的朋友来玩。
我已经能够使用在沙箱中运行的 2 部或更多部 iPhone 来邀请特定的朋友来玩,并且它对于调试邀请处理程序代码段非常有效。
正如另一位发帖者提到的,目前似乎没有一种方法可以邀请特定的朋友从游戏中心玩特定的游戏。
游戏愉快!
I could be wrong, but i think it is just the "simulator" that can not invite particular friends to play.
I have been able to use 2 or more iPhones running in the sandbox to invite particular friends to play, and it has worked wonderfully for debugging the invite handler piece of code.
As another poster mentioned, there does not appear to be at this time a way of inviting particular friends to play a particular game from Game Center.
Happy gaming!