3

I'm implementing my first Turn Based game with Game Center, and I'm having a difficult time understanding who receives the notification from player(_:wantsToQuitMatch:).

Does the current player who is quitting (via some in-game quitting method) get this notification? Do other players get the notification when the current player quits? What happens if the current player quits from within Game Center (removes the game)?

I've tried removing a game in Game Center, when it's my turn, and the method doesn't get triggered for the players still in the game. I can't get that method to trigger.

coopersita
  • 5,011
  • 3
  • 27
  • 48

2 Answers2

2

After several years of working with GKTurnBasedMatch, I have Never seen wantsToQuitMatch fire. Never. Not once.

The (massively overloaded) function, receivedTurnEventForMatch is the only function that will fire when a player joins or leaves. (See my answer at https://stackoverflow.com/a/34458493/1641444 for more information about when each of the functions fire). It's a pain because receivedTurnEventForMatch fires in many difference circumstances and it's left up to you to decipher which one triggered it.

This wasn't your question, but as you're just starting out with turn based matches, if you're not too heavily invested yet, I suggest you consider the new GKGameSession announced at WWDC this year. GKTurnBasedMatch has numerous constraints that can leave games stranded (can't be continued by any player). I'm just beginning to look into Game Sessions myself; however, at first glance, they give you much greater control plus a significantly larger match data object (512kB vs 64kB).

Community
  • 1
  • 1
Thunk
  • 4,099
  • 7
  • 28
  • 47
  • Thanks. I'll take a look at GKGameSession. – coopersita Aug 20 '16 at 22:58
  • I just checked the WWDC session, and I have a few questions. Will GKGameSession only be available for iOS 10+? I'd like to still support iOS 8+. Do you think GKGameSession will eventually replace GKTurnBasedMatch? Looks much better, but I'm lazy, and already coded a good portion of my app (it's a hobby app, so need be I can recode, no deadline) – coopersita Aug 21 '16 at 18:43
  • Game Session does appear to be ios10+. If turn based matches are working for you, then it may not be worth changing. I've had a really bad experience with turn based matches, so I'm eager to move. Even though it means losing 32-bit devices that can't run IOS 10. – Thunk Aug 21 '16 at 18:58
  • Thanks, again. This was super helpful. I'll have to think about it, since my app's audience likely includes older people that probably stick to older devices. – coopersita Aug 21 '16 at 19:03
1

I am seeing player(_:wantsToQuitMatch:) fire when I call up the GameCenter view and tap on the game I am currently taking a turn in and try to "Forfeit" that game. While I do see it fire, I am not yet sure what to do with it. Currently I am doing nothing and the player does not get out of the game.

EFC
  • 1,890
  • 18
  • 39