当我点击这里的按钮是我的代码时,我无法显示成就和排行榜并提交分数: -
此处,单击按钮
时,排行榜和成就无法打开protected static final int REQUEST_LEADERBOARD = 0;
protected static final int REQUEST_ACHIEVEMENTS = 0;
@Override
public void onClick(View v) {
if (v.getId() == R.id.scoreButton)
{
counter++;
giveAchievements(counter);
textScore.setText(""+counter);
}
if(v.getId() == R.id.show_achievements)
{
startActivityForResult(Games.Achievements.getAchievementsIntent(getApiClient()), REQUEST_ACHIEVEMENTS);
}
if(v.getId() == R.id.show_leaderboard){
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient,
getString(R.string.leaderboard_leaderboard)), REQUEST_LEADERBOARD);
}
}
这里的分数没有提交到排行榜,但游戏的成就是在不给出xp或分数的情况下解锁: -
void giveAchievements(int counter)
{
if (counter == 7)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_first_10_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
}
if (counter == 50)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_50_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(),getString(R.string.leader board_leaderboard), counter*100);
} if (counter == 100)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_100_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
} if (counter == 7)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_250_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), "CgkI-eXOwZsFEAIQBg", counter*100);
} if (counter == 500)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_500_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
} if (counter == 1000)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_1000_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
} if (counter == 1500)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_1500_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
} if (counter == 3000)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_3000_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
} if (counter == 5000)
{ if(getApiClient().isConnected())
Games.Achievements.unlock(getApiClient(),
getString(R.string.achievement_5000_clicks));
Games.Leaderboards.submitScoreImmediate(getApiClient(), getString(R.string.leaderboard_leaderboard), counter*100);
}
}
这是截图成就卡在10000 here is the screenshot