Real-time multiplayer Google Play game combined with LibGDX

I'm new to game development, and I'm struggling a bit with combining the functionality of google play multiplayer in my game in LibGDX. I do not find many textbooks regarding this online.

I downloaded the BaseGameUtils library and everything is connected (my signIn method works), and I use interfaces to combine the android package with my main package.

In my AndroidLauncher, I have this code:

@Override
public void startQuickGame() {
    final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 1;
    Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS, MAX_OPPONENTS, 0);

    RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder((RoomUpdateListener) this);
    rtmConfigBuilder.setMessageReceivedListener((RealTimeMessageReceivedListener) this);
    rtmConfigBuilder.setRoomStatusUpdateListener((RoomStatusUpdateListener) this);
    rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);

    //prevent screen from sleeping
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Games.RealTimeMultiplayer.create(gameHelper.getApiClient(), rtmConfigBuilder.build());
}

I am trying to use the code in my menu class:

@Override
protected void handleInput() {
    if (Gdx.input.justTouched() && isOnBtn()) {
        try {
            crush.playServices.startQuickGame();
        } catch (Exception e) {
            e.printStackTrace();
        }
        gsm.set(new OnlineMultiplayerState(gsm));
        dispose();

I'm not sure how I should start the game? At the moment, everything is just black.

I would also like to use code for methods like handleSelectPlayersResult (int response, Intent data)

, , , Intent Android ( , ). , ?

!

+4

Source: https://habr.com/ru/post/1695942/


All Articles