2013-05-22 24 views
0

我已成功整合了Google Play遊戲服務。我正在使用此服務的多玩家功能。現在我面臨一個問題。使用Google Play遊戲服務成功創建房間之後強力啓動遊戲android

後成功創建遊戲房間,在onRoomCreated接收回調()方法

@Override 
public void onRoomCreated(int statusCode, Room room) { 
    Log.d(TAG, "onRoomCreated(" + statusCode + ", " + room + ")"); 
    if (statusCode != GamesClient.STATUS_OK) { 
     Log.e(TAG, "*** Error: onRoomCreated, status " + statusCode); 
     showGameError(); 
     return; 
    } 

    // show the waiting room UI 
    final int MIN_PLAYERS = 2; 
    Intent i = getGamesClient().getRealTimeWaitingRoomIntent(room, MIN_PLAYERS); 
    startActivityForResult(i, RC_WAITING_ROOM); 

    // here i want to add timer *** 
} 

這裏我想補充定時器。在特定的時間之後,如果房間裏至少有2個用戶,我想強制開始遊戲。我怎麼能做到這一點。

我想在onRoomConnected(int statusCode,Room room)回調方法後開始的特定時間後開始遊戲。

谷歌播放服務在我們在MIN_PLAYERS中提到的特定用戶數後啓動遊戲。但我想開始後特定時間的遊戲後不特定的用戶數

getGamesClient().getRealTimeWaitingRoomIntent(room, MIN_PLAYERS); 

回答

0

你能避免使用getRealTimeWaitingRoomIntent意圖和直接調用broadcastStart(); (true);gameStart(true);這兩種方法來自谷歌Play遊戲服務的官方樣本)在您的計時器的特定時間後。

請記住,您將不得不管理一些空間更新的回調,這取決於你的使用情況,也可能是onPeerDeclinedonPeerJoinedonPeerLeft,[...]和/或onPeersConnected

如果您想顯示播放器信息,您也必須自己實施。