{"id":30332,"date":"2023-01-14T14:25:09","date_gmt":"2023-01-14T08:55:09","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/"},"modified":"2023-01-14T14:25:09","modified_gmt":"2023-01-14T08:55:09","slug":"solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/","title":{"rendered":"[Solved] How can I make an online 2 player game in Cocos2d X? [closed]"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-13948848\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"13948848\" data-parentid=\"13948449\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<pre><code>with help of apple game center you can implement multiplayer very early.\n\nfor example\n\n#import &lt;Foundation\/Foundation.h&gt;\n#import &lt;GameKit\/Gamekit.h&gt;\n\n@interface GCHelper : NSObject&lt;GKMatchmakerViewControllerDelegate, GKMatchDelegate&gt;\n{\n    BOOL isUserAuthenticated;\n\n    UIViewController *presentingViewController;\n    GKMatch *match;\n    BOOL matchStarted;\n\n    GKInvite *pendingInvite;\n    NSArray *pendingPlayersToInvite;\n    NSMutableDictionary *playersDict;\n\n    NSString *MultiplayerID;\n    NSData *MultiData;\n    NSString *otherPlayerID;\n\n    char AlertMessageBoxNo;\n\n    BOOL isDataRecieved;\n}\n\n\/\/variables\n\n@property (assign, readonly) BOOL gameCenterAvailable;\n@property (retain) UIViewController *presentingViewController;\n@property (retain) GKMatch *match;\n@property (retain) GKInvite *pendingInvite;\n@property (retain) NSArray *pendingPlayersToInvite;\n@property (retain) NSMutableDictionary *playersDict;\n\n@property (retain) NSString *MultiplayerID;\n@property (retain) NSData *MultiData;\n\n-(NSString*)getOtherPlayerId;\n-(void)setOtherPlayerId;\n\/\/Functions\n+ (GCHelper *)sharedInstance;\n-(BOOL)isGameCenterAvailable;\n-(void)authenticationChanged;\n-(void)authenticateLocalUser;\n\n-(void)gameOver:(NSString*)message;\n\n-(void)setDataRecieved:(BOOL)d;\n-(BOOL)getDataRecieved;\n\n\n- (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController;\n\n\/\/\/\/\/\/\/\/\/\/\/\n\n\n\n#import \"GCHelper.h\"\n#import \"IPadSharebleClass.h\"\n\n\n@implementation GCHelper\n\n@synthesize gameCenterAvailable;\n@synthesize presentingViewController;\n@synthesize match;\n@synthesize pendingInvite;\n@synthesize pendingPlayersToInvite;\n@synthesize playersDict;\n@synthesize MultiData;\n@synthesize MultiplayerID;\n\nstatic GCHelper *sharedHelper = nil;\n\n+(GCHelper *) sharedInstance\n{\n    if (!sharedHelper)\n    {\n        sharedHelper = [[GCHelper alloc] init];\n    }\n    return sharedHelper;\n}\n\n\n- (BOOL)isGameCenterAvailable\n{\n    Class gcClass = (NSClassFromString(@\"GKLocalPlayer\"));\n    NSString *reqSysVer = @\"4.1\";\n    NSString *currSysVer = [[UIDevice currentDevice] systemVersion];\n    BOOL osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);\n    return (gcClass &amp;&amp; osVersionSupported);\n}\n\n\n- (id)init\n{\n    if ((self = [super init]))\n    {\n        gameCenterAvailable = [self isGameCenterAvailable];\n        if (gameCenterAvailable)\n        {\n            NSNotificationCenter *nc =\n            [NSNotificationCenter defaultCenter];\n            [nc addObserver:self\n                   selector:@selector(authenticationChanged)\n                       name:GKPlayerAuthenticationDidChangeNotificationName\n                     object:nil];\n        }\n        else\n        {\n            UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Game Center Not Available\" delegate:nil cancelButtonTitle:@\"OK\" otherButtonTitles:nil, nil];\n            [alert show];\n            [alert release];\n        }\n    }\n    return self;\n}\n\n-(void)authenticationChanged\n{\n    if ([GKLocalPlayer localPlayer].isAuthenticated &amp;&amp; !isUserAuthenticated)\n    {\n        NSLog(@\"Authentication changed: player authenticated.\");\n        isUserAuthenticated = TRUE;\n\n        [GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite)\n        {\n            NSLog(@\"Received invite\");\n            self.pendingInvite = acceptedInvite;\n            self.pendingPlayersToInvite = playersToInvite;\n            IPadCallAnyWhereF.inviteReceived();\n        };\n\n    }\n    else if (![GKLocalPlayer localPlayer].isAuthenticated &amp;&amp; isUserAuthenticated)\n    {\n        NSLog(@\"Authentication changed: player not authenticated\");\n        isUserAuthenticated = FALSE;\n    }\n}\n\n- (void)authenticateLocalUser\n{\n    if (!gameCenterAvailable) return;\n\n    NSLog(@\"Authenticating local user...\");\n    if ([GKLocalPlayer localPlayer].authenticated == NO)\n    {\n        [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil];\n    }\n    else\n    {\n        NSLog(@\"Already authenticated!\");\n    }\n}\n\n-(void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController\n{\n    if (!gameCenterAvailable) return;\n\n    matchStarted = NO;\n    self.match = nil;\n    self.presentingViewController = viewController;\n    if (pendingInvite != nil)\n    {\n        [presentingViewController dismissModalViewControllerAnimated:NO];\n        GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:pendingInvite] autorelease];\n        mmvc.matchmakerDelegate = self;\n        [presentingViewController presentModalViewController:mmvc animated:YES];\n\n        self.pendingInvite = nil;\n        self.pendingPlayersToInvite = nil;\n    }\n    else\n    {\n        [presentingViewController dismissModalViewControllerAnimated:NO];\n        GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];\n        request.minPlayers = minPlayers;\n        request.maxPlayers = maxPlayers;\n        request.playersToInvite = pendingPlayersToInvite;\n\n        GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];\n        mmvc.matchmakerDelegate = self;\n\n        [presentingViewController presentModalViewController:mmvc animated:YES];\n\n        self.pendingInvite = nil;\n        self.pendingPlayersToInvite = nil;\n\n    }\n\n}\n\n\n#pragma mark GKMatchmakerViewControllerDelegate\n- (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController *)viewController\n{\n    [presentingViewController dismissModalViewControllerAnimated:YES];\n\n    UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Game Cancel By you\" delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n    [alert show];\n    [alert release];\n    AlertMessageBoxNo='E';\n}\n\n- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error\n{\n    [presentingViewController dismissModalViewControllerAnimated:YES];\n    NSLog(@\"Error finding match: %@\", error.localizedDescription);\n    UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Connection Time out\" delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n    [alert show];\n    [alert release];\n    AlertMessageBoxNo='A';\n}\n\n\n- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)theMatch\n{\n    [presentingViewController dismissModalViewControllerAnimated:YES];\n    self.match = theMatch;\n    match.delegate = self;\n    if (!matchStarted &amp;&amp; match.expectedPlayerCount == 0)\n    {\n        NSLog(@\"***************Ready to start match!**************\");\n        [self lookupPlayers];\n    }\n}\n\n- (void)lookupPlayers\n{\n    NSLog(@\"Looking up %d players...\", match.playerIDs.count);\n    [GKPlayer loadPlayersForIdentifiers:match.playerIDs withCompletionHandler:^(NSArray *players, NSError *error)\n     {\n         if (error != nil)\n         {\n             NSLog(@\"Error retrieving player info: %@\", error.localizedDescription);\n             matchStarted = NO;\n             \/\/IPadCallAnyWhereF.matchEnded();\n             UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Error retrieving player info\" delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n             [alert show];\n             [alert release];\n             AlertMessageBoxNo='F';\n         }\n         else\n         {\n             self.playersDict = [NSMutableDictionary dictionaryWithCapacity:players.count];\n             for (GKPlayer *player in players)\n             {\n                 NSLog(@\"Found player: %@\", player.alias);\n                 [playersDict setObject:player forKey:player.playerID];\n             }\n             NSLog(@\"Total Number of Players : %d\",players.count);\n             matchStarted = YES;\n             IPadCallAnyWhereF.matchStarted();\n         }\n     }];\n\n}\n\n#pragma mark GKMatchDelegate\n- (void)match:(GKMatch *)theMatch didReceiveData:(NSData *)data fromPlayer:(NSString *)playerID\n{\n    if (match != theMatch) return;\n\n    MultiData=data;\n    MultiplayerID=playerID;\n    if(otherPlayerID==nil)\n    {\n        otherPlayerID=[playerID retain];\n    }\n    IPadCallAnyWhereF.match();\n}\n\n-(void)setDataRecieved:(BOOL)d\n{\n    isDataRecieved=d;\n}\n-(BOOL)getDataRecieved\n{\n    return isDataRecieved;\n}\n\n\n-(NSString*)getOtherPlayerId\n{\n    return otherPlayerID;\n}\n\n-(void)setOtherPlayerId\n{\n    otherPlayerID=nil;\n}\n\n- (void)match:(GKMatch *)theMatch player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state\n{\n    if (match != theMatch) return;\n    switch (state)\n    {\n        case GKPlayerStateConnected:\n            NSLog(@\"New Player connected!\");\n            if (!matchStarted &amp;&amp; theMatch.expectedPlayerCount == 0)\n            {\n                NSLog(@\"&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp; Ready to start match in the match!\");\n                [self lookupPlayers];\n            }\n            break;\n        case GKPlayerStateDisconnected:\n            NSLog(@\"--------Player disconnected!--------\");\n            matchStarted = NO;\n            UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Player Disconnected\" delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n            [alert show];\n            [alert release];\n            AlertMessageBoxNo='B';\n            \/\/IPadCallAnyWhereF.matchDisconnect();\n            break;\n    }\n}\n\n- (void)match:(GKMatch *)theMatch connectionWithPlayerFailed:(NSString *)playerID withError:(NSError *)error\n{\n    if (match != theMatch) return;\n\n    NSLog(@\"Failed to connect to player with error: %@\", error.localizedDescription);\n    matchStarted = NO;\n    \/\/IPadCallAnyWhereF.matchEnded();\n    UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Failed to connect to player\" delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n    [alert show];\n    [alert release];\n    AlertMessageBoxNo='C';\n\n}\n\n- (void)match:(GKMatch *)theMatch didFailWithError:(NSError *)error\n{\n    if (match != theMatch) return;\n\n    NSLog(@\"Match failed with error: %@\", error.localizedDescription);\n    matchStarted = NO;\n    \/\/IPadCallAnyWhereF.matchEnded();\n    UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:@\"Match failed\" delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n    [alert show];\n    [alert release];\n    AlertMessageBoxNo='D';\n\n}\n\n-(void)gameOver:(NSString*)message\n{\n    UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@\"Game Center Alert\" message:message delegate:self cancelButtonTitle:@\"Try Again\" otherButtonTitles:@\"Main Menu\", nil];\n    [alert show];\n    [alert release];\n    AlertMessageBoxNo='G';\n}\n\n-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex\n{\n    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];\n\n    if([title isEqualToString:@\"Try Again\"])\n    {\n        IPadCallAnyWhereF.matchDisconnect();\n    }\n    else if([title isEqualToString:@\"Main Menu\"])\n    {\n        IPadCallAnyWhereF.gotoMainMenu();\n    }\n\n}\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">4<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How can I make an online 2 player game in Cocos2d X? [closed] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] with help of apple game center you can implement multiplayer very early. for example #import &lt;Foundation\/Foundation.h&gt; #import &lt;GameKit\/Gamekit.h&gt; @interface GCHelper : NSObject&lt;GKMatchmakerViewControllerDelegate, GKMatchDelegate&gt; { BOOL isUserAuthenticated; UIViewController *presentingViewController; GKMatch *match; BOOL matchStarted; GKInvite *pendingInvite; NSArray *pendingPlayersToInvite; NSMutableDictionary *playersDict; NSString *MultiplayerID; NSData *MultiData; NSString *otherPlayerID; char AlertMessageBoxNo; BOOL isDataRecieved; } \/\/variables @property (assign, readonly) BOOL &#8230; <a title=\"[Solved] How can I make an online 2 player game in Cocos2d X? [closed]\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\" aria-label=\"More on [Solved] How can I make an online 2 player game in Cocos2d X? [closed]\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[1162,5736],"class_list":["post-30332","post","type-post","status-publish","format-standard","hentry","category-solved","tag-cocos2d-x","tag-multiplayer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How can I make an online 2 player game in Cocos2d X? [closed] - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How can I make an online 2 player game in Cocos2d X? [closed] - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] with help of apple game center you can implement multiplayer very early. for example #import &lt;Foundation\/Foundation.h&gt; #import &lt;GameKit\/Gamekit.h&gt; @interface GCHelper : NSObject&lt;GKMatchmakerViewControllerDelegate, GKMatchDelegate&gt; { BOOL isUserAuthenticated; UIViewController *presentingViewController; GKMatch *match; BOOL matchStarted; GKInvite *pendingInvite; NSArray *pendingPlayersToInvite; NSMutableDictionary *playersDict; NSString *MultiplayerID; NSData *MultiData; NSString *otherPlayerID; char AlertMessageBoxNo; BOOL isDataRecieved; } \/\/variables @property (assign, readonly) BOOL ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-14T08:55:09+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How can I make an online 2 player game in Cocos2d X? [closed]\",\"datePublished\":\"2023-01-14T08:55:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\"},\"wordCount\":30,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"cocos2d-x\",\"multiplayer\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\",\"name\":\"[Solved] How can I make an online 2 player game in Cocos2d X? [closed] - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2023-01-14T08:55:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How can I make an online 2 player game in Cocos2d X? [closed]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How can I make an online 2 player game in Cocos2d X? [closed] - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How can I make an online 2 player game in Cocos2d X? [closed] - JassWeb","og_description":"[ad_1] with help of apple game center you can implement multiplayer very early. for example #import &lt;Foundation\/Foundation.h&gt; #import &lt;GameKit\/Gamekit.h&gt; @interface GCHelper : NSObject&lt;GKMatchmakerViewControllerDelegate, GKMatchDelegate&gt; { BOOL isUserAuthenticated; UIViewController *presentingViewController; GKMatch *match; BOOL matchStarted; GKInvite *pendingInvite; NSArray *pendingPlayersToInvite; NSMutableDictionary *playersDict; NSString *MultiplayerID; NSData *MultiData; NSString *otherPlayerID; char AlertMessageBoxNo; BOOL isDataRecieved; } \/\/variables @property (assign, readonly) BOOL ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/","og_site_name":"JassWeb","article_published_time":"2023-01-14T08:55:09+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How can I make an online 2 player game in Cocos2d X? [closed]","datePublished":"2023-01-14T08:55:09+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/"},"wordCount":30,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["cocos2d-x","multiplayer"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/","url":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/","name":"[Solved] How can I make an online 2 player game in Cocos2d X? [closed] - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-01-14T08:55:09+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-can-i-make-an-online-2-player-game-in-cocos2d-x-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How can I make an online 2 player game in Cocos2d X? [closed]"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=30332"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30332\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=30332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=30332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=30332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}