@Override protected void onCreate(Bundle savedInstanceState) { Log.e(TAG, "onCreate"); super.onCreate(savedInstanceState); MyAppApplication myApp = ((MyAppApplication) getApplicationContext()); mGoogleApiClient = myApp.getClient(); room = myApp.getRoom(); mRoomId = room.getRoomId(); mParticipants = room.getParticipants(); Intent i = getIntent(); myself = (Player) i.getSerializableExtra("myself"); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); initialize(new CatMath(this, myself), config); // updated by siyuan myId = room.getParticipantId(Games.Players.getCurrentPlayerId(myApp.getClient())); GameWorld.isOwner = isServer(); Log.e("isOwner:", String.valueOf(GameWorld.isOwner)); playerMap.put(myId, 1); GameWorld.numberOfPlayers = mParticipants.size(); Log.e(TAG, "onCreate ends"); } // end of onCreate
@Override public void showAchievement() { if (isSignedIn() == true) { startActivityForResult( Games.Achievements.getAchievementsIntent(myApp.getClient()), requestCode); // , getString(R.string.achievement_dum_dum) } else { signIn(); } }
@Override public void startQuickGame() { Log.e(TAG, "startQuickGame"); final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 2; Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS, MAX_OPPONENTS, 0); RoomConfig.Builder roomConfigBuilder = RoomConfig.builder(this); roomConfigBuilder.setMessageReceivedListener(this); roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria); RoomConfig roomConfig = roomConfigBuilder.build(); // create room: Games.RealTimeMultiplayer.create(myApp.getClient(), roomConfig); // NEXT: onRoomCreated }