libgdx:unlocked成就弹出窗口未显示

时间:2015-11-30 22:29:57

标签: java android libgdx google-play-services google-play-games

此网站中的某些用户问我的问题unlocked-popup-not-showingUnlocked Achievement Popup not shown,但对我不起作用我不知道我的代码有什么问题?

首先清除所有用户的问题。我的问题是如何显示解锁Achievement的弹出式通知?喜欢这张图片:

enter image description here

其次我的android类MainActivity实现了以下内容:

public class MainActivity extends AndroidApplication implements IGoogleServices, GameHelperListener {
     private GameHelper _gameHelper;
.......

IGoogleServices接口是:

public interface IGoogleServices {
    .....
    public boolean isSignedIn();
    public void unlockAchievement(String achievementId);
    public void showAchievements();
}

第三次 onCreate方法中的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

    // Create the GameHelper.
    _gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
    _gameHelper.enableDebugLog(true);

    _gameHelper.setup(this);

    initialize(new MyGdxGame(this, this), config);
}

第四实施方法:

@Override
public void unlockAchievement(String achievementId) {
    if (isSignedIn()) {
        Games.Achievements.unlock(_gameHelper.getApiClient(), achievementId);
    }
}

第五次我将IGoogleServices界面投入MyGdxGame游戏:

public MyGdxGame(IGoogleServices googleServices) {
    this.googleServices = googleServices;
}

最后我创建了Image按钮来解锁第一个成就:

final Image iAch1 = new Image(ach1);
iAch1.addListener(new InputListener() {
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        return true;
    }
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
        googleServices.unlockAchievement("CgkIzZ.......");
    }
});
stage.addActor(iAch1);

到目前为止一切正常,Achievements解锁没有弹出窗口 通知如上图所示。我怎样才能做到这一点?

0 个答案:

没有答案