【问题标题】:Google Play Games Service crash LibGDX GameGoogle Play 游戏服务崩溃 LibGDX 游戏
【发布时间】:2015-10-07 01:41:48
【问题描述】:

我尝试在我的 LibGDX 游戏中实现 Google Play 游戏服务器。如果我开始我的游戏,它的工作时间为 10 秒,但在这 10 秒之后,我的游戏崩溃了,我不知道为什么。我希望你能帮忙。

这里是代码

import android.os.Bundle;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.games.Games;
import com.google.android.*;
import com.randomsoftwareindustries.bubbleburster.bubbleburster;

public class AndroidLauncher extends AndroidApplication implements GameHelper.GameHelperListener{

GameHelper gameHelper;

@Override
protected void onCreate (Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    config.useAccelerometer = false;
    config.useCompass = false;
    config.useWakelock = true;
    gameHelper = new GameHelper(this,GameHelper.CLIENT_ALL);
    gameHelper.enableDebugLog(true);
    initialize(new LIBGDXGAME(), config);
    gameHelper.setup(this);

}

@Override
public void onStart() {
    super.onStart();
    gameHelper.onStart(this);
}

@Override
public void onStop() {
    super.onStop();
    gameHelper.onStop();
}

@Override
public void onSignInFailed() {
    // TODO Auto-generated method stub
    System.out.println("Sign in failed");
}

@Override
public void onSignInSucceeded() {
    // TODO Auto-generated method stub
    System.out.println("Sign in succeeded");
}

}

【问题讨论】:

    标签: java android libgdx google-play-games


    【解决方案1】:

    尝试在 onCreate 中使用此代码:

    if (gameHelper == null) {
            gameHelper = new GameHelper(this, GameHelper.CLIENT_ALL); //maybie CLIENT_GAMES?
            gameHelper.enableDebugLog(true);
        }
        gameHelper.setup(this);
    
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new LIBGDXGAME(this), config)
    

    还检查我的问题和答案。 Maybie 你会发现一些有用的东西: link

    【讨论】:

    • 它现在可以工作,但我认为我的代码不是问题;)我没有添加这个 在清单中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    • 2015-05-08
    • 1970-01-01
    • 1970-01-01
    • 2014-02-02
    • 2013-05-30
    相关资源
    最近更新 更多