Google Play Game Services

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Hi

Im releasing v1.0.1 of my Module for Google Game Services.
==EDIT== V2 has been released https://www.cerberus-x.com/community/threads/google-play-game-services-v1-0-1.475/post-8530

If you are interested on how I built it, I've written up a blog post here

Module can be downloaded from here

The module is fully documented. Please read this as there are a few extra files needed to make it work.

Comments welcome

example
Code:
gms = New GameService()

If MouseHit(MOUSE_LEFT)

  If MouseY()<200
    ' sign in/out
    If gms.IsSignedIn()
      gms.SignOut()
    Else
      gms.SignIn()
    End
  Else
    If MouseY()<400
      gms.SubmitLeaderboardScore("CgkIzeqAseADEAIQAQ",Rnd(100000))
    Else
      If MouseY()<600
        gms.ShowLeaderboard("CgkIzeqAseADEAIQAQ")
      Else
        If MouseY()<800
          gms.UnlockAchievement("CgkIzeqAseADEAIQAw")
        Else
          If MouseY()<1000
            gms.ShowAchievements()
          End
        End
      End
    End
  End       
End

Rich
 
Last edited:

itto

New member
Joined
Jun 8, 2020
Messages
8
Hi, is this module still working to this day?

I've been trying to make it work but I'm encountering some issues. In debug mode, I get the "Signing in" toast and the Google Play message "Connecting to Play Games", but after a while it disappears and none of this module's functions work. In production mode, the app crashes on startup.

Just wanted to make sure this code is still working before spending lots of time debugging :)
 

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Hi @itto
Its been a while since i looked at this. CX has a few updates since i released it 2 years ago.
Ill have a look this week and update as necessary
Rich
 

itto

New member
Joined
Jun 8, 2020
Messages
8
Hi Rich,

Thank you, I can say that after a false start and some head bashing I was able to make everything work! My problem was to add the right SHA1 codes for google play services to work. The test one was missing, and the release one was somehow wrong. After adding those I was able to make work both leaderboard and achievements :)

One thing I changed to your code is the addition of some code to make the native popup appear, for example when you unlock an achievement.

inside the IsSignedIn() method:

Java:
if (!popupViewInitialized && GoogleSignIn.getLastSignedInAccount(_activity) != null) {

  GamesClient gamesClient = Games.getGamesClient(_activity, GoogleSignIn.getLastSignedInAccount(_activity));

  gamesClient.setViewForPopups(_activity.findViewById(android.R.id.content));

  gamesClient.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

  popupViewInitialized = true;

}

popupViewInitialized is a static boolean simply to take make sure we do this only once.

Unfortunately I noticed callback functions aren't available to Cerberus, so I ended up polling the IsSignedIn method every second or so to check whether the user is signed in and enable/disable the buttons for leaderboard and achievements accordingly. It would be great if we could have a callback to pass to the login method, to react upon the user successfully logging in or not, but oh well :)

Thanks a lot for this module, it works great so far! :)
 

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Great to know it's still working. I can see that modules need updating, I'll have a look

When it comes to IsSignedIn, I just use it in an if statement in my OnUpdate() and OnRender()

Code:
If IsSignedIn()
  cnvs.DrawImage active_button_img,x,y
else
  cnvs.DrawImage grey_button_img,x,y
end

As to the addition.. I cant picture what your trying to in the IsSignedIn function. The IsSignedIn should just return true or false
If its a one off thing, my suggestion would be to put it in the SignIn function
 

itto

New member
Joined
Jun 8, 2020
Messages
8
Yes that's not the best place to put it in, I just wanted to try it out quickly.

The thing is, that code should run only once, so ideally the module should have an Init() method or something similar.

I'm not sure that code can be in the SignIn function because for that code to run, we need to retrieve the already signed-in instance, and I thought that method might run asynchronously.

Do you think it might be possible to implement events like signed in successfully or not, etc. in your module? I know we don't have callbacks but we could use interfaces to pass a class instance which will implement the right callback methods. I'm just not too familiar with Java so I'm not sure if it's possible to do it natively :)
 

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Do you think it might be possible to implement events like signed in successfully or not, etc. in your module?
I think it is possible, I'm not an expert. The store module does something similar when buying items
 

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Last edited:

itto

New member
Joined
Jun 8, 2020
Messages
8
Hi @Rich, thanks for the update! I just had a quick look at the code, and I love the addition of the ids.xml file directly so I don't have to do it manually every time I make a new build. I didn't know something like this was possible in Cerberus at all.

I'm busy integrating other APIs at the moment, but when I have time I will contribute with displaying the cool popups.
 

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
...I love the addition of the ids.xml file directly so I don't have to do it manually every time I make a new build. I didn't know something like this was possible in Cerberus at all.
Its been around for quite a while since the early days of monkey.There was fix in the last update of CX, so hence i can use it again.Its great for including files and populating information. I can update my Appodeal module.
Theres also a libs var so you can include jars easily
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
571
How does Appodeal compare to Admob? I'm thinking of adding some ads to a game but it's a big decision,
what's the pros and cons when using Appodea instead of Admobl?
 
Top Bottom