0

i have integrated google play game service successfully. i am using multi-player feature of this service. now i am facing an issue.

after successfully creation of game room and receiving call back in onRoomCreated() method

@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 ***
}

here i want to add timer. after a specific time i want to forcefully start the game play if there is minimum 2 user in the room. how can i achieve this.

i want to start the game after specific time which starts after onRoomConnected(int statusCode, Room room) call-back method.

google play service starts the game after specific user count which we mention in MIN_PLAYERS. but i want to start the game after specific time not after specific user count

getGamesClient().getRealTimeWaitingRoomIntent(room, MIN_PLAYERS);
adnan_it
  • 88
  • 1
  • 7

1 Answers1

0

You can avoid using getRealTimeWaitingRoomIntent intent and directly call broadcastStart(); and gameStart(true); (these two methods come from the official samples for Google Play game services) after a specific time with your timer.

Keep in mind you will have to manage some room update callbacks, depending on your use-cases, it could be onPeerDeclined, onPeerJoined, onPeerLeft, [...] and/or onPeersConnected.

Same goes if you want to display player(s) information, you will have to implement it yourself.

Aladin Q
  • 550
  • 5
  • 12