Bug in Turn Based Multiplayer Game Center In iOS 8.3 -
i want make turn based mutiplayer puzzle type game.it's works fine functionality inlcuding notification of player' turn end.but in ios 8.3 can't delegate method calld while player turn end .any solution?
i registered listener.but it's not called.here code..
- (void)authenticatelocaluser { if (!gamecenteravailable) return; nslog(@"authenticating local user..."); if ([gklocalplayer localplayer].authenticated == no) { __weak typeof(self) weakself = self; __weak gklocalplayer *weakplayer = [gklocalplayer localplayer]; weakplayer.authenticatehandler = ^(uiviewcontroller *viewcontroller, nserror *error) { if (viewcontroller != nil) { [weakself showauthenticationdialogwhenreasonable:viewcontroller]; } else if (weakplayer.isauthenticated) { // player has been authenticated! [weakplayer unregisteralllisteners]; [weakplayer registerlistener:weakself]; // gkturnbasedeventhandler *ev = // [gkturnbasedeventhandler sharedturnbasedeventhandler]; // ev.delegate = self; } else { // should disable game center? } }; } }
since mention ending turn, maybe experiencing bug introduced in ios8.3 broke notifications after active player calls endturnwithnextparticipants, discussed here: endturnwithnextparticipants doesn't trigger receivedturneventformatch after update ios 8.3 , swift 1.2
a couple of work around proposed there, solution i've found works reliably set timer loop on non-active devices , keep reloading match data until see become current participant. use:
-(void)ismatchactive:(nstimer *)timer { nsstring *matchid = (nsstring *)timer.userinfo; [gkturnbasedmatch loadmatchwithid:matchid withcompletionhandler:^(gkturnbasedmatch *match, nserror *error) { gklocalplayer *localplayer = [gklocalplayer localplayer]; gkturnbasedparticipant *currentparticipant = match.currentparticipant; if ([localplayer.playerid isequaltostring:currentparticipant.player.playerid]) { //we have become active. call event handler it's supposed called [self player:localplayer receivedturneventformatch:match didbecomeactive:false]; } else { //we still waiting become active. check float dtime = 5.0; gamecontroller.ios8bugtimer = [nstimer scheduledtimerwithtimeinterval:dtime target:self selector:@selector(ismatchactive:) userinfo:matchid repeats:no]; } }]; }
Comments
Post a Comment