Fast 3 gamecenter: the number of participants is always 4

I made a TurnBased game that worked great at speed 2. I could successfully change the code to swift 3.2 and fix all the errors around 400, but there is one problem with the game center that I cannot figure out how to fix it. When through the gamecenter viewcontroler I set the member number to “2Player” and then click “Invite Friends”, the number of players I get is 4 instead of 2! gamecenter sends a text message to the next participant, in which the number of participants is 4. This, of course, affects the rest of the program to a problem that I did not 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 something to my code or change something in it?

+4
1

ios. .

0

Source: https://habr.com/ru/post/1668145/


All Articles