gpt4 book ai didi

iphone - 使用游戏中心向所有玩家显示相同的牌

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:46:53 24 4
gpt4 key购买 nike

我是 Game Center 的新手,我已经设法邀请 friend 并成功打开了按钮的 IBAction。

我正在使用 GKTurnbasedMatch 来管理回合,但对于多人游戏,如何向邀请玩家选择其类别的所有玩家显示卡片。

我怎样才能得到这个?

最佳答案

这是有关 Gamecenter/回合制的精彩教程:

http://www.raywenderlich.com/5509/beginning-turn-based-gaming-with-ios-5-part-2

特别是这部分:

If we find that lastTurn is null, we’ll assume that we’re dealing with a new match, otherwise we’ll assume that we already have matchData that we’ll be dealing with. So open up GCTurnBasedMatchHelper.m and replace the didFindMatch method as follows:

-(void)turnBasedMatchmakerViewController: 
(GKTurnBasedMatchmakerViewController *)viewController
didFindMatch:(GKTurnBasedMatch *)match {
[presentingViewController
dismissModalViewControllerAnimated:YES];
self.currentMatch = match;
GKTurnBasedParticipant *firstParticipant =
[match.participants objectAtIndex:0];
if (firstParticipant.lastTurnDate) {
NSLog(@"existing Match");
} else {
NSLog(@"new Match");
}
}

您要做的是每轮将所有数据发送给所有玩家,因此当玩家第一次开始(发牌)时,他们应该将手牌发送给所有玩家。当他们不交易时,您不必发送所有数据,因此您可以发送不同类型的消息。发送信息:

BOOL success = [[GameCenterManager sharedInstance].Match sendDataToAllPlayers:data  withDataMode:GKMatchSendDataReliable error:&error];

只要确保数据有类型,这通常是消息的第一个字节,然后在客户端,读取第一个字节以确定它是什么类型的消息,然后使用 switch 语句或任何你喜欢处理不同类型的消息。

关于iphone - 使用游戏中心向所有玩家显示相同的牌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13656635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com