Sign In Register

How can we help you today?

Start a new topic
Answered

How to use libgdx with Game Sparks

Hi,


Just wondering, is there a way to use game sparks with libgdx? Do I have to create bridges in Android and IOS to do this?


Best Answer

Hi Lam,

Sorry we missed this.
It is possible to use 
libgdx with GameSparks. Let us know if you are still creating this project and we'll see if we can help.

Thanks,

Oisin


Answer

Hi Lam,

Sorry we missed this.
It is possible to use 
libgdx with GameSparks. Let us know if you are still creating this project and we'll see if we can help.

Thanks,

Oisin

Hi,


I'm very interested in to know if it's possible to integrate GameSparks on LibGDX. I saw you have an Android SDK version. Does it can be used to integrate on LibGDX? Does it use some Android sdk dependency so it can't be reused on java projects?


Thanks,

Aecio 

Hi there, after some research I decided to try integrate GameSparks by myself. For my surprise it's pretty easy, salvo some gradle configuration. Anyway, I decided to write a blog post about it: http://www.locomotivemobile.com/devlog/2016/03/18/libgdx-and-gamesparks/


Hope I can help someway.

Hello Aecio Lima Ribeiro, can you share the code to IGSPlatform. Its not documented anywhere on how to implements it. In your blog, you have CustomPlatform class, can you share how to implement it?

Hey azli,


I've implemented the code based on Android sample code, from here:


https://bitbucket.org/gamesparks/gamesparks-android-sdk/src/c0e7d30f076aafc5f7984e6010006cd05f9c13bf/gamesparks-android-client-sdk/src/main/java/com/gamesparks/sdk/android/GSAndroidPlatform.java?at=master&fileviewer=file-view-default


So, I've created this code:


public class CustomPlatform implements IGSPlatform {


    @Override

    public File getWritableLocation() {

        return null;

    }


    @Override

    public void executeOnMainThread(Runnable runnable) {

    }


    @Override

    public String getPlayerId() {

        return null;

    }


    @Override

    public String getAuthToken() {

        return null;

    }


    @Override

    public void setPlayerId(String s) {

    }


    @Override

    public void setAuthToken(String s) {

    }


    @Override

    public Object getHmac(String nonce, String secret) {

        try {

            Mac sha256_HMAC = Mac.getInstance("HmacSHA256");

            SecretKeySpec secretKeySpec = new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256");

            sha256_HMAC.init(secretKeySpec);


            return Base64Coder.encode(sha256_HMAC.doFinal(nonce.getBytes("UTF-8")));

        } catch(Exception e) {

            return null;

        }

    }


    @Override

    public void logMessage(String s) {

    }


    @Override

    public void logError(Throwable throwable) {

    }

}


Hope, this can help you.

Regards


1 person likes this

Thanks Aecio! I will try it out. Good to see some LibGDX user here :)

Hello, Aecio Lima Ribeiro

this getHmac() function makes some error


 {"@class":".AuthenticatedConnectResponse","error":"ERROR Unrecognized token 'C': was expecting ('true', 'false' or 'null')\n at [Source: {\"platform\":\"Service API Tests\",\"hmac\":[C@fb02ffd,\"@class\":\".AuthenticatedConnectRequest\"}; line: 1, column: 42]","requestId":"0"

like this.


is there another way to use that function?

Thanks~

class LibGdxPlatform implements IGSPlatform {
@Override
public File getWritableLocation() {
return null;
}

@Override
public void executeOnMainThread(Runnable runnable) {
Gdx.app.postRunnable(runnable);
}

@Override
public String getPlayerId() {
return null;
}

@Override
public String getAuthToken() {
return null;
}

@Override
public void setPlayerId(String s) {

}

@Override
public void setAuthToken(String s) {

}

@Override
public Object getHmac(String nonce, String secret) {
try
{
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256");

sha256_HMAC.init(secret_key);

//return Base64.encodeBase64String(sha256_HMAC.doFinal(nonce.getBytes("UTF-8")));
return new String(Base64Coder.encode(sha256_HMAC.doFinal(nonce.getBytes("UTF-8"))));
}
catch (Exception e)
{
return null;
} }

@Override
public void logMessage(String s) {
Gdx.app.log("Gamesparks", s);
}

@Override
public void logError(Throwable throwable) {
Gdx.app.error("Gamesparks", throwable.getMessage(), throwable);
}
}

 

Login to post a comment