集成 libGDX 游戏与 google 玩游戏 借助 android 基本示例的排行榜

integrating libGDX Game with google play games Leaderboards wit help of android basic examples

我有一个用 LibGDX 编写的游戏,我想在其中集成 google 游戏服务排行榜。我已经阅读了 google 提供的用于在下面的存储库

中实现排行榜的基本示例的代码

https://github.com/playgameservices/android-basic-samples

TypeANumber 是一个实现排行榜的项目。 TypeANumber 中的 MainActivity 扩展了 class FragmentActivity,它由 google 提供,需要在我的游戏中扩展,同样 libGDX 游戏 class 也扩展了 AndroidApplication Class需要扩展 libGDX Framework .

现在 Java 不支持多重继承,我需要你的帮助来扩展这两个 classes。到目前为止,我已经实现了所有其他必需的接口。

提前致谢

那些碎片其实就是游戏的状态。 您不必扩展片段。

只需将 googleplaygamesservices 方法添加到从核心目录实现接口的 androidlauncher。 因此,您可以在核心中创建此接口的实例,并能够从实际游戏代码中调用 gameservices 方法。 这是我在核心中名为 PlayServices 的接口。

public interface PlayServices
{
public void signIn();
public void signOut();
public void rateGame();
public void unlockAchievement(String str);
public void submitScore(int highScore);
public void submitLevel(int highLevel);
public void showAchievement();
public void showScore();
public void showLevel();
public boolean isSignedIn();
public void showBannerAd();
public void hideBannerAd();
public void showInterstitialAd (Runnable then);
public void showRewardedVideo();
public boolean isRewardEarned();
}

如您所见,我不仅使用排行榜,还使用多种服务,例如所有类型的广告、成就等。

这是我的 game.Google Play 服务的开源版本,但逻辑是一样的。

https://github.com/ahmetdenizyilmaz/connect

游戏link如果你想看看他们在行动

https://play.google.com/store/apps/details?id=com.ady.connect