[Huawei Developers] Freemind R:
More information like this, you can visit HUAWEI Developer Forum​

Original link: https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201320947104400266&fid=0101187876626530001

Hi folks! In this guide I’ll explain how to integrate the Huawei Game Service with gdx-gamesvcs, a libGDX extension library for Game Services.

Medium Link: https://medium.com/huawei-developers/huawei-game-service-for-libgdx-games-3b189d8b4a82

What’s gdx-gamesvcs?

gdx-gamesvcs is a libGDX extension that aims to provide a cross-platforms API

for Game Services.

It supports the following services:

• Google Play Games;

• Apple Game Center;

• GameJolt;

• Amazon GameCircle;

• Kongregate;

• Huawei Game Service (starting from version 1.1.0-SNAPSHOT version)

For further information, please visit: https://github.com/MrStahlfelge/gdx-gamesvcs

Huawei Game Service for libGDX

It supports the following features:

- Account Kit: login, logout;

- Game Service: player info, achievements, leaderboards, game events;

- Drive Kit: save, load and delete data on Cloud

Requirements

• EMUI 3.0+ / Android 4.4+

• HMS Core 4.0.0.300+

• Android Studio 3.0+

Preparation

• Create an app in AppGallery Connect. The app type must be Game.

• Create a libGDX project.

• Generate a signature certificate.

• Generate a signature certificate fingerprint.

• Configure the signature certificate fingerprint.

• Add the app package name and save the configuration file.

• Configure the Maven repository address and AppGallery Connect gradle

plug-in.

• Configure the signature file in Android Studio.

For further information, please visit: https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html#0

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/105/845/0890039000024105845.20200806105701.35926447946066830622896210545185:50510820054831:2800:8BFD2AD02069E9F262CFEE56783D33436380490D0AB19129D1ECB3BCB1BEBE3D.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/105/845/0890039000024105845.20200806105701.35926447946066830622896210545185:50510820054831:2800:8BFD2AD02069E9F262CFEE56783D33436380490D0AB19129D1ECB3BCB1BEBE3D.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/105/845/0890039000024105845.20200806105804.46647681425088367102052232030641:50510820054831:2800:C4E9B3E5D0D45316EEC23895634A39B4C94BE7CBBF239FD885BC57BA4221BA0A.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/105/845/0890039000024105845.20200806105804.46647681425088367102052232030641:50510820054831:2800:C4E9B3E5D0D45316EEC23895634A39B4C94BE7CBBF239FD885BC57BA4221BA0A.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/105/845/0890039000024105845.20200806105915.93012822761629591759242988132411:50510820054831:2800:875647268962C0CE840944BF2AB4E9C0EE9827586367B4D57F05C883A8275005.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/024/105/845/0890039000024105845.20200806105915.93012822761629591759242988132411:50510820054831:2800:875647268962C0CE840944BF2AB4E9C0EE9827586367B4D57F05C883A8275005.png[/IMG]

Finally coding!

Gradle:

implementation “de.golfgl.gdxgamesvcs:gdx-gamesvcs-android-huawei:1.1.0-SNAPSHOT”

Now, in your Activity extending the AndroidApplication class (a libGDX class), optionally implementing the IGameServiceListener (to listen events), You have to instantiate the HuaweiGameServicesClient, and then manage the lifecycle events. Like this:

public class GameServiceActivity extends AndroidApplication implements IGameServiceListener {
private IGameServiceClient gsClient = null;

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

//true if You want to manage data on Cloud
this.gsClient = HuaweiGameServicesClient(this, true);
this.gsClient.setListener(this);

initialize(gdxGameSvcsApp, config);
}

@Override
protected void onPause() {
super.onPause();

if (this.gsClient != null) {
this.gsClient.pauseSession();
}
}

@Override
protected void onResume() {
super.onResume();

if (this.gsClient != null) {
this.gsClient.resumeSession();
}
}

@Override
public void gsOnSessionActive() {
Log.d("SESSION", "ACTIVE");
}

@Override
public void gsOnSessionInactive() {
Log.d("SESSION", "INACTIVE");
}

@Override
public void gsShowErrorToUser(GsErrorType et, String msg, Throwable t) {
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
}

So? Unleash the power of the HuaweiGameServiceClient!

...
//ACCOUNT KIT
gsClient.logIn();
gsClient.logOff();

//GAME SERVICE
//achievements
gsClient.showAchievements();
gsClient.unlockAchievement("id");
gsClient.incrementAchievement("id", increment, completionPercentage);
gsClient.fetchAchievements(new IFetchAchievementsResponseListener() {
@Override
public void onFetchAchievementsResponse(Array<IAchievement> achievements) {

}
});

//leaderboards
gsClient.showLeaderboards("id");
gsClient.submitToLeaderboard("id", score, scoreTips);
gsClient.fetchLeaderboardEntries("id", limit, isRelatedToPlayer, new IFetchLeaderBoardEntriesResponseListener() {
@Override
public void onLeaderBoardResponse(Array<ILeaderBoardEntry> leaderBoard) {

}
});

//game events
gsClient.submitEvent("id", increment);

//DRIVE KIT
gsClient.saveGameState(null, gameState, progressValue, new ISaveGameStateResponseListener() {
@Override
public void onGameStateSaved(boolean success, String errorCode) {

}
});
gsClient.loadGameState(null, new ILoadGameStateResponseListener() {
@Override
public void gsGameStateLoaded(byte[] gameState) {

}
});
gsClient.deleteGameState(null, new ISaveGameStateResponseListener() {
@Override
public void onGameStateSaved(boolean success, String errorCode) {

}
});

...

Do You want moaAAaaRrRr?

Read my article about Huawei IAP for libGDX: Medium

https://medium.com/huawei-developers/huawei-iap-for-libgdx-games-eb5aec5662af