2014-02-14 2 views
2

나는 턴 기반 멀티 플레이어 Android 앱을 개발 중입니다.이 새로운 수신기를 사용하는 방법

처음에, 나는 TurnBasedMultiplayerListener를 구현하고 onTurnBasedMatchInitiated을 무시했지만, 이제 인터페이스는 사용되지 않으며 나는 그것을 사용하는 방법을 잘 모릅니다, this listener

문제는 사용해야합니다. 클래스를 인터페이스로 구현하도록 만들었고 메소드를 재정의했습니다.

다음과 같이 나는 다음 turnBasedGame을 만들 ...

PendingResult<InitiateMatchResult> f = 
    Games.TurnBasedMultiplayer.createMatch(gApiClient, tbmc); 

그리고 지금 나는 f.setResultCallback(...) 말을 생각하지만 난 그 안에 무엇을 넣어 잘 모릅니다.

제안 사항?

답변

2

ResultCallback을 매개 변수로 구현 한 클래스를 제공해야합니다.

public void MatchInitiatedCallback implements ResultCallback { 

    @Override 
    public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) { 
     // Check if the status code is not success; 
     if (result.getStatus != GamesStatusCodes.STATUS_OK) { 
      showError(statusCode); 
      return; 
     } 

     TurnBasedMatch match = result.getMatch(); 

     // If this player is not the first player in this match, continue. 
     if (match.getData() != null) { 
      showTurnUI(match); 
      return; 
     } 

     // Otherwise, this is the first player. Initialize the game state. 
     initGame(match); 

     // Let the player take the first turn 
     showTurnUI(match); 
    } 
} 

참조 : https://developers.google.com/games/services/android/turnbasedMultiplayer#selecting_players_with_the_default_user_interface

+0

나는 그 전에 시도했습니다. 그것은 void가 MatchInitiatedCallback에 대해 유효하지 않은 유형이라고합니다 – Ogen

+0

nevermind 나는 그것을 고쳤습니다. – Ogen

관련 문제