开发者

Game Center - Reconnecting to game

开发者 https://www.devze.com 2023-03-10 12:42 出处:网络
In a multiplayer game set up by Game Center API, the game could disconnect if one of the players had to quit unexpectedly for a 开发者_开发百科minute or more. This could happen for example when the pl

In a multiplayer game set up by Game Center API, the game could disconnect if one of the players had to quit unexpectedly for a 开发者_开发百科minute or more. This could happen for example when the player received a phone call. When that happens, and after the player resumed the game, is there a way to automatically reconnect him to the game?


It's going to depend greatly on if you established the session via p2p Bluetooth/Wifi or over the Internet.

From the GameCenter docs:

Adding Players to an Existing Match Sometimes you may already have a match, and just want to add players to it. For example, if your game requires four players and a player gets disconnected, you might want to offer the option to find a replacement, instead of aborting the match in progress.

To do this, you use code similar to that found in Listing 5-7, but instead of calling the findMatchForRequest:withCompletionHandler:, your application calls the addPlayersToMatch:matchRequest:completionHandler: method, adding the match to add the players to as an additional parameter.

So basically, if you still have a match object, you can reuse it on either end. It's up to you and your game to figure out what makes the most sense.


I don't believe this can be done in iOS4. HINT HINT

0

精彩评论

暂无评论...
验证码 换一张
取 消