59731

how to sync data in multiplayer game(game-center ios)

Question:

I have been developing a game for Game Center.

<strong>Description of game :-</strong>

One player is initiator of game because game has 5 tiled-map (only one tile-map is selected randomly by either player(initiator)) . Initiator will send selected tile-map to second player, Now this tile-map will draw on second player side.(at this point both player have same tile-map)

This is work fine when I start game by sending invitation to player.

but when I start game by "automatch" , I am not able to find that who will be the initiator(who will send randomly selected tile-map).

I have made one player initiator by this code:

isThisInvited_Player = YES; [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_INVITATION_ACCEPTED object:nil]; - (void)authenticationChanged { if ([GKLocalPlayer localPlayer].isAuthenticated && !userAuthenticated) { userAuthenticated = TRUE; [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) { isThisInvited_Player = YES; self.pendingInvite = acceptedInvite; self.pendingPlayersToInvite = playersToInvite; [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_INVITATION_ACCEPTED object:nil]; }; } else if (![GKLocalPlayer localPlayer].isAuthenticated && userAuthenticated) { userAuthenticated = FALSE; } }

if data sync is not possible in "automatch", then please tell me , how can I disable the automatch(Play) button in game-center-view-controller.

Answer1:

You could pick who the initiator is by sorting the two players by their playerIDs and then always have the first one in the sorted array be the initiator.

Recommend

  • .htaccess code to protect a single URL?
  • what GKSession doesn't connect on every attempt?
  • Send notification when inviting to multiplayer game (Game Services)
  • Conversion of my alfresco javascript file into java class [duplicate]
  • Facebook C# SDK: Traverse The JsonArray To Get The Value of Tracking Data
  • Renewing Cookie-session for express.js
  • How to Cache Images Dynamically-Generated with PHP?
  • passing parameter to server in ExtJs
  • retrieving data from url in iphone
  • chrome video src change not working
  • How can I run DataNucleus Bytecode Enhancer from SBT?
  • Repository Browser Only - \"Repository moved permanently to… please relocate”
  • CSS bleed-through with cfinput type=“datefield”
  • Group list of tuples by item
  • 550 Access denied - Invalid HELO name
  • Cannot upload to OneDrive using the new SDK
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • Lost migrations and Azure database is now out of sync
  • Get one-time binding to work for ng-if
  • Dynamically accessing properties of knockoutjs observable array
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Sony Xperia Z Tablet not found by adb
  • How would I use PHP exceptions to define a redirect?
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How to extract text from Word files using C#?
  • How can I estimate amount of memory left with calling System.gc()?
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • python regex in pyparsing
  • Acquiring multiple attributes from .xml file in c#
  • Hits per day in Google Big Query
  • need help with bizarre java.net.HttpURLConnection behavior
  • Android Google Maps API OnLocationChanged only called once
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • How to load view controller without button in storyboard?