回合制多人应用程序两个玩家都不能转弯
Posted
技术标签:
【中文标题】回合制多人应用程序两个玩家都不能转弯【英文标题】:Turnbased multiplayer app both players cant take a turn 【发布时间】:2014-03-04 11:24:43 【问题描述】:当您在我的国际象棋应用程序上点击 Play! 时,它会将您带到选择玩家屏幕,如下所示...
注意:mGamesClient 是使用mGamesClient.connect()
连接的GameClient
。
Intent intent = mGamesClient.getSelectPlayersIntent(1, 1, true);
startActivityForResult(intent, RC_SELECT_PLAYERS);
现在,在我选择了我的玩家(只有一名玩家,因为它是国际象棋)之后,我收到了 onActivityResult
回调,看起来像这样......
@Override
public void onActivityResult(int request, int response, Intent data)
super.onActivityResult(request, response, data);
if (request == RC_SELECT_PLAYERS)
if (response != Activity.RESULT_OK)
// user canceled
return;
// get the invitee list
final ArrayList<String> invitees = data
.getStringArrayListExtra(GamesClient.EXTRA_PLAYERS);
// get auto-match criteria
Bundle autoMatchCriteria = null;
int minAutoMatchPlayers = data.getIntExtra(
GamesClient.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
int maxAutoMatchPlayers = data.getIntExtra(
GamesClient.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);
if (minAutoMatchPlayers > 0)
autoMatchCriteria = RoomConfig.createAutoMatchCriteria(
minAutoMatchPlayers, maxAutoMatchPlayers, 0);
else
autoMatchCriteria = null;
TurnBasedMatchConfig tbmc = TurnBasedMatchConfig.builder()
.addInvitedPlayers(invitees)
.setAutoMatchCriteria(autoMatchCriteria).build();
// kick the match off
mGamesClient.createTurnBasedMatch(this, tbmc);
Log.v("LOG", "+++ ONACTIVITYRESULT HOMESCREENACTIVITY +++");
现在因为 mGamesClient.createTurnBasedMatch(this, tbmc);
被调用,我得到一个 onTurnBasedMatchInitiated
回调,看起来像这样......
@Override
public void onTurnBasedMatchInitiated(int statusCode, TurnBasedMatch match)
Log.v("LOG", "+++ ONTURNBASEDMATCHINITIATED HOMESCREENACTIVITY +++");
mMatch = match;
// Check if the status code is not success;
if (statusCode != GamesClient.STATUS_OK)
showErrorMessage(statusCode);
Log.v("LOG", "" + statusCode);
return;
Intent i = new Intent(getApplicationContext(), OfflineInGameActivity.class);
i.putExtra("soundOn", soundOn);
i.putExtra("LoLImages", LoLImages);
startActivity(i);
return;
现在我的国际象棋活动开始了。在我的对手方,他/她收到了邀请,如果被接受,将调用acceptTurnBasedInvitation
。
现在我的问题是,没有一个玩家可以移动,因为它说没有轮到每个玩家。
【问题讨论】:
【参考方案1】:这应该会有所帮助:
Deciding who is player one and two in a round based game with Google Play Game Services
以下是谷歌文档中的相关部分:
https://developers.google.com/games/services/android/turnbasedMultiplayer#taking_the_first_turn
【讨论】:
我不再需要这个了,我已经修复它并发布了应用程序。但是感谢您的回答,我相信它会帮助我解决它:)以上是关于回合制多人应用程序两个玩家都不能转弯的主要内容,如果未能解决你的问题,请参考以下文章
用户点击通知时如何直接打开Android回合制多人应用程序?
将 Google 回合制多人游戏与 Google App Engine 集成