Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends AndroidApplication implements GameServiceInterface, GameHelper.GameHelperListener {
- protected GameHelper mHelper;
- final static int RC_UNUSED = 9002;
- public MainActivity() {
- mHelper = new GameHelper(this);
- //mHelper.enableDebugLog(true, "MYTAG");
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- Game.setPlatformResolver(new AndroidResolver());
- AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
- cfg.useGL20 = true;
- cfg.useAccelerometer = false;
- cfg.useCompass = false;
- mHelper.setup(this);
- initialize(new Game(this, cfg);
- }
- @Override
- public void onStart() {
- super.onStart();
- mHelper.onStart(this);
- }
- @Override
- public void onStop() {
- super.onStop();
- mHelper.onStop();
- }
- @Override
- public void onActivityResult(int request, int response, Intent data) {
- super.onActivityResult(request, response, data);
- mHelper.onActivityResult(request, response, data);
- }
- @Override
- public void showAchievements() {
- if (isSignedIn()) {
- startActivityForResult(mHelper.getGamesClient().getAchievementsIntent(), RC_UNUSED);
- } else {
- }
- }
- @Override
- public void showScores() {
- if (isSignedIn()) { startActivityForResult(mHelper.getGamesClient().getLeaderboardIntent(getString(R.string.leaderboard_stars)), RC_UNUSED);
- } else {
- }
- }
- @Override
- public boolean isSignedIn() {
- return mHelper.isSignedIn();
- }
- @Override
- public void logOut() {
- try {
- runOnUiThread(new Runnable() {
- // @Override
- public void run() {
- mHelper.signOut();
- }
- });
- } catch (final Exception ex) {
- }
- }
- @Override
- public void login() {
- try {
- runOnUiThread(new Runnable() {
- // @Override
- public void run() {
- mHelper.beginUserInitiatedSignIn();
- }
- });
- } catch (final Exception ex) {
- }
- }
- @Override
- public void submitScore(int score) {
- if (mHelper.isSignedIn()){
- mHelper.getGamesClient().submitScore(getString(R.string.leaderboard_stars), score);
- }
- }
- @Override
- public void onSignInFailed() {
- System.out.println("Sign in failed");
- }
- @Override
- public void onSignInSucceeded() {
- System.out.println("Sign in succeeded");
- }
- @Override
- public void unlockAchievements(String achievementID) {
- if (mHelper.isSignedIn()){
- mHelper.getGamesClient().unlockAchievement(achievementID);
- }
- else {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement