2014-04-08 1 views
3

보드 게임을 개발 중입니다. 멀티 플레이를 위해 Game Center를 사용하지만 현재는 GKTurnBasedMatch의 초대장을 보내거나받는 방법에 얽매여 있습니다.GKTurnBasedMatch의 초대장을 보내고 받으십시오.

GKMatchRequest *request = [[GKMatchRequest alloc] init]; 
request.defaultNumberOfPlayers = 2; 

[GKTurnBasedMatch findMatchForRequest:request 
        withCompletionHandler: 
          ^(GKTurnBasedMatch *match, NSError *error) { 
           if(error) { 
            NSLog(@"%@", error.localizedDescription); 
            return; 
           } 
           [self.delegate startGameForMatch:match]; 
          }]; 

위의 블록의 매개 변수에 GKTurnBasedMatch 인스턴스가, nil 다른 플레이어와 로컬 플레이어를 가지고 있는데 게임에서 상대의 세부 사항을 표시해야합니다 내가 사용하여 프로그래밍 방식으로 경기를 만드는 오전.

NSMutableArray *participantIds = [[NSMutableArray alloc] init]; 
NSLog(@"%@", match.participants); 
for (GKTurnBasedParticipant *participant in match.participants) { 
    if(participant.playerID) [participantIds addObject:participant.playerID]; 
} 
[GKPlayer loadPlayersForIdentifiers:participantIds 
      withCompletionHandler:^(NSArray *players, NSError *error) { 
       NSMutableString *string = [[NSMutableString alloc] init]; 
       for (GKPlayer *player in players) { 
        [string appendFormat:@"---- Alias: %@ DisplayName: %@", player.alias, player.displayName]; 
       } 
       NSLog(@"%@", string); 
      }]; 

누락 된 항목이나 Game Center가 있습니까? 경기가 시작될 때 상대방의 세부 정보를 표시해야합니다. 이 GKTurnBasedMatch.currentParticipant이 될 때까지 경기 참가자는 초대장을받지 못합니다.

도움 주셔서 감사합니다. 올바른 방향으로 나를 가리켜 라.

+0

또한 새로운 GKTurnBasedMatch를 만들 때마다 GKTurnBasedParticipant 0x146b2360-playerID : (null) 상태 : matchingOutcome : None lastTurnDate : (null) timeoutDate : (null))> "상대방 참가자로" –

+0

같은 문제가 있습니까? 아직 진행 상황이 있습니까? – JehandadK

답변

-1

이것은 임의의 상대와의 대전을 만들 때 발생합니다. iTunesConnect에서 두 번째 테스트 사용자를 만들고 두 번째 장치에서 해당 사용자와 서명하십시오.

그런 다음 두 번째 테스트 플레이어에게 친구로 초대하십시오. 이렇게하면 임의로 일치하는 것을 기다리지 않고 멀티 플레이어 기능으로 게임을보다 쉽게 ​​테스트 할 수 있습니다.

친구 요청이 수락되면 다시 한 번 새로운 게임을 만드십시오. 이제 '친구'를 게임에 초대하고 차례를 시작하십시오. 이제 (null) 변수가 채워질 것임을 알게 될 것입니다.이 같은 것이 당신의 로그에 나타납니다.

GKTurnBasedParticipant 0xb9432e0 - playerID : G : 123456789 상태 : 초청 matchOutcome : 없음 lastTurnDate : null (null) timeoutDate : (null)

+0

질문과 전혀 관련이 없음 –