Android game with OpenFeint
Tell me how to properly implement the features OpenFeint in my game for Android. I'm quite a beginner, so need help.
I spent the initialization OpenFeint, made a button on the dashboard in the main menu of the game, everything works fine. Can not get to realize achievements.
I do so (in the same class where initialize OpenFeint):
final Achievement a = new Achievement("1239817");
if(mGameThread.mCurrentLevel >= 2) {
a.unlock(new Achievement.UnlockCB () {
@Override public void onSuccess(boolean complete) {
Toast.makeText(main.this, "Unlocked", Toast.LENGTH_SHORT).show();
开发者_Go百科 main.this.setResult(Activity.RESULT_OK);
main.this.finish();
}
@Override public void onFailure(String exceptionMessage) {
Toast.makeText( main.this,
"Error (" + exceptionMessage + ") unlocking achievement.",
Toast.LENGTH_SHORT).show();
main.this.setResult(Activity.RESULT_CANCELED);
main.this.finish();
}
});
}
I think it's about the condition if (mGameThread.mCurrentLevel >= 2), it somehow does not want to run. I'm so if a player has reached level 2, achieving unlocked. In the game I was not very convenient construction, only one Activity-element, in which I initialize OpenFeint and achievements for the game, everything else is done in the class GameView (to upload data from other classes).
Help. Any ideas. Can achieve OpenFeint placed in a separate Activity? (Achievements.java?)
What you've got there looks like it should be correct, and you should be able to split off the Achievement specific code to a different file if it makes everything easier to keep track of without a problem.
If you can't get OpenFeint working for you, check out Swarm, which provides a very similar system (but maybe it makes more sense for you specifically) :)
精彩评论