如何在LibGdx中使用Google Play游戏服务

Paw*_*nr1 5 java android libgdx google-play-games

我想在我的LibGDX And​​roid游戏中使用Google Play游戏服务API的成就和排行榜.我唯一能做的就是从Game Services开发者网站上运行示例.我一直试图在我的项目中使用这段代码很多天,我什么都没有.我也试过按照这个教程http://helios.hud.ac.uk/u1070589/blog/?p=202但我没有"主要游戏类(从ApplicationListener扩展的那个)"这是在步骤7中需要.我只有

  • 公共类DogeJump扩展了Game
  • 公共类MainActivity扩展AndroidApplication实现IActivityRequestHandler
  • 公共类BaseScreen实现了Screen
  • 公共类GameScreen扩展了负责游戏玩法的BaseScreen //

这是来自MainActivity.java的onCreate方法

    protected void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);
        thingy=this;

        RelativeLayout layout=new RelativeLayout(this);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        View gameView=initializeForView(new DogeJump(this),false);

        adView=new AdView(this,AdSize.IAB_MRECT,"ca-app-pub-XXXXXXX363095/9011689567");

        adView.loadAd(new AdRequest());

        layout.addView(gameView);
        RelativeLayout.LayoutParams adParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
        adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
        adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layout.addView(adView,adParams);       



        setContentView(layout);

        //initialize(new DogeJump(this),false);
    }
Run Code Online (Sandbox Code Playgroud)

ssa*_*tos 2

在我的脑海中,Game类应该实现ApplicationListener,因此您缺少遵循教程的类应该是DogeJump