I am new to game development, and i'm struggling a bit with combining the google play service realtime multiplayer functionality in my LibGDX game. I do not find a lot of tutorials regarding this online.
I have downloaded the BaseGameUtils library, and everything is connected (my signIn method works), and i'm using interfaces to combine the android package with my core 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 try 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 about how i should actually start the game? At this point, everything just go black.
I would also like to use the code for methods like handleSelectPlayersResult(int response, Intent data)
The problem is that when i try to define this method in my interface, it wont work because Intent only work in the Android package (not in core where my interface is). Do you have an suggestion to how i can solve this?
Thank You!