简体   繁体   中英

How-to use Scoreloop's award system in libGDX game

I want to use Scoreloop achievements in my game. I configured bundle with icons on their site and added bundle to assets. And when run Scorellop EntryActivity I had Achievements activity. But now I need set progress to achievements from my game, but I can't understand how do it. Documentation from Scoreloop site is not cleared for me. Can someone provide me sample code?

 public void achieve(final String awardId) {
    ScoreloopManagerSingleton.get().loadAchievements(null);

    // final String awardId = context.getResources().getString(resId);

    // i.e. wait with the unlocking and/or display of achievements until your runnable gets invoked.
    ScoreloopManagerSingleton.get().loadAchievements(new Continuation<Boolean>() {
      @Override
      public void withValue(Boolean arg0, Exception arg1) {
        Achievement achivment = ScoreloopManagerSingleton.get().getAchievement(awardId);
        if (achivment.getAward().getAchievingValue() - achivment.getValue() == 1) {
          ScoreloopManagerSingleton.get().achieveAward(achivment.getAward().getIdentifier(), true, true);
        } else {
          if (!achivment.isAchieved()) {
            achivment.incrementValue();
          }

          if (achivment.needsSubmit()) {
            AchievementController aController = new AchievementController(
                new RequestControllerObserver() {

                  public void requestControllerDidReceiveResponse(RequestController arg0) {
                    // TODO Auto-generated method stub

                  }

                  public void requestControllerDidFail(RequestController arg0, Exception arg1) {
                    // TODO Auto-generated method stub

                  }
                });

            aController.setAchievement(achivment);
            aController.submitAchievement();
          }
        }
      }

    });
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM