swift 3 游戏中心:参与者数量始终为 4 [英] swift 3 gamecenter: number of participants are always 4
问题描述
我制作了一款与 swift 2 完美配合的 TurnBased 游戏.我可以成功地将代码更改为 swift 3.2 并纠正所有关于 400 的错误,但是游戏中心存在一个问题,我无法弄清楚如何修复它.当通过gamecenter viewcontroler我将参与者的数量设置为2Player"然后推送邀请朋友"时,我得到的玩家数量是4而不是2!游戏中心向下一个参与者发送一条短信,其中参与者的数量也是 4.这当然会影响程序的其余部分,这是我在 Swift 2 中没有的问题.这是我的代码的一部分:
I made a TurnBased game that was working perfectly with swift 2. I could successfully change the code to swift 3.2 and correct all the errors about 400, but there is one issue with the game centre that I can not figure out how to fix it. When through gamecenter viewcontroler I set the number of the participant to "2Player" and then push "Invite Friends" the number of Player that I get is 4 instead of 2! the gamecenter send a text message to the next participant in which the number of participant is 4 too. This of course affect the rest of the program a problem that I didn’t have in Swift 2. This is part of my code:
func joinTurnBasedMatch()
{
let request = GKMatchRequest()
request.minPlayers = 2
request.maxPlayers = 4
request.defaultNumberOfPlayers = 2
let tbvc = GKTurnBasedMatchmakerViewController(matchRequest: request)
tbvc.turnBasedMatchmakerDelegate = self
present(tbvc, animated: true, completion: nil)
}
func turnBasedMatchmakerViewController(_ viewController: GKTurnBasedMatchmakerViewController, didFind match: GKTurnBasedMatch)
{
self.dismiss(animated: true, completion: nil)
self.performSegue(withIdentifier: "To_ViewC_CG", sender: match)
print("*** Number OF Players ***")
print(match.participants!.count)
}
我需要在代码中添加任何内容或更改其中的任何内容吗?
Do I need to add anything to my code or change anything in it?
推荐答案
该问题已在最新的ios更新中解决.现在它完美地工作.
The problem has been solved in the latest ios update. Now it works perfectly.
这篇关于swift 3 游戏中心:参与者数量始终为 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!