Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

WOW! Steps to set a simple leaderboard in Google Play Services console!
Started by LairdGames Feb 12 2014 02:03 AM

25 replies to this topic
[TOPIC CONTROLS]
Page 1 of 2 1 2
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

Hello guys,

 

I have a general question about setting up Google Play Services so I can set up a simple leaderboard for one my upcoming app. I found this great tutorial

 

http://coronalabs.com/blog/2013/06/25/tutorial-introducing-google-play-game-services/

 

Which has this scary looking link with TONS of steps to get a simple leaderboard going.

 

Do I really need to go thru all these to setup my leaderboard? I do not even need achievements.

 

I hope not! I thought GameCenter was hard but this has to be the most complex services have seen or maybe I am simply use to GameCenter too much :)

 

Thanks for any input.

 

Mo

 



[TOPIC: post.html]
#2

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

And I thought I must be the only one in the whole wide world to feel this way... only yesterday I was going through the same questions... And today is day 2...

 

A wise person told me if you don't want to use Achievements thats fine. Just set 5 of them to tick the box and forget about them. 



[TOPIC: post.html]
#3

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

Thanks @ksan. LOL! Yes it seems to be a process from hell! So you confirm that list of steps is really the way to go :(

 

I think I will go slow on this one. Thank you for the achievements tip! I may use them after all:) Still I would love to hear also from people who went thru hellish list of steps :) So we can avoid some common issues that may arise.

 

Good luck and please share any tips if any. I will do the same.

 

Thank you again.

 

Mo



[TOPIC: post.html]
#4

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

Got my Android 2.2 device soft-bricked trying to upgrade it to 2.3... Read that GPGS on 2.2 is not optimal so I thought I should go 2.3 and now I'm wasting time trying to recover this POS... It being my only Android device and me being not in a mood to buy any new devices put me in a predicament... So tip #1... read the instructions and follow them to the letter while in Android land. It is treacherous! 



[TOPIC: post.html]
#5

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

WOW! That's does not sound good. I have a feeling that too will suffer since I do not even have an Android device to test. I do have a new Kindle Fire HD but not sure that would work with GPGS. I will assume not.

 

Man, good luck!

 

Mo



[TOPIC: post.html]
#6

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

From what I read I think you can test GPGS on Kindle Fire HD. Might be wrong of course but I think I saw something to that end. 

 

Thanks for your kind thoughts. Fish out of water is how I feel right now. Good luck as you tread through those steps. Do you have ADT (Android Developer Tools) installed on your Mac/PC? 



[TOPIC: post.html]
#7

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

Cool! Yes I know how you feel! No, but I should install ADT on my Macbook. Just starting with Android side of things so I need to get setup. I released an app on Android/Amazon that was not too bad but this GPGS is going to take a while. Still, other did it so can we :) (trying to cheer myself...) 

 

Cheers.

 

Mo



[TOPIC: post.html]
#8

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

Ok. POS phone un-bricked and successfully upgraded to Android 2.3.5 and app still behaving the same way. So back to square one... Re-reading all the instructions and processing once again. Am I really this slow? :-(



[TOPIC: post.html]
#9

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

LOL! No I am afraid that those instructions make GC integration a child play. I am working on something else right but soon I will need to go thru that list and start calling for my mommy :)

 

Good luck and keep us posted on your "great" adventure!

 

Mo 



[TOPIC: post.html]
#10

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

A trip to shops, a new Nexus 7 later I was still nowhere further. Thanks to some great friendly advice I ran through the whole sequence and now I have an operational leaderboard!!! Yayy. Pay attention to the steps around creating the client and the SHA1 creation from your keystore etc. Good luck. 



[TOPIC: post.html]
#11

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

Yaaaaa! Good for you! I am too chicken to start :) I will do it when I had bunch of wine....how long did it took you? Great job! Mo

[TOPIC: post.html]
#12

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

How long did it take... Not that long, each time. I ended up doing it 3 times altogether. First the attempt with debug SHA1, second one worked but I didn't like the way it looked so had to nuke it and start over and third time's a charm. Altogether less than an hour I'd say not including the time to read and research. You'll be fine.



[TOPIC: post.html]
#13

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

LOL! The more I read the instructions the more I get affraid! But I think it will be ok. I just need sometime. I may also have couple questions after reading those instructions. Just things that are little confusing at first. I will post them when I get there. Thank you Ksan. Mo

[TOPIC: post.html]
#14

lKinx

[GLOBAL: userInfoPane.html]
lKinx
  • Starter
  • PipPipPipPipPipPip
  • 178 posts
  • Jedi

Here's a module I made that handles logging in, posting to a leaderboard, and earning achievements. It works for both Game Center and Google Play, assuming that both have the same Leaderboard ID and Achievement IDs (Apple let's you set these, so just copy the Google Play IDs).

 

This file assumes you've created the leaderboards/achievements in Google Play, and have set up your build.settings file accordingly.

local gameNetwork = require("gameNetwork")

local this = {}

local function gameNetworkListener(event)
    local targetAppStore = system.getInfo("targetAppStore")
    if event.data and targetAppStore == "apple" then
        this.isLoggedIn = true
    elseif targetAppStore ~= "apple" and not event.isError then
        local type = event.type
        if type == "init" then
            this.hasInitialized = true
            gameNetwork.request("login", {userInitiated = true, listener = gameNetworkListener})
        elseif type == "login" then
            this.isLoggedIn = true
        end
    end
end

function this.checkAchievements(value, type)
    if type == "score" then
        if value == 500 then
            gameNetwork.request("unlockAchievement", {achievement = {identifier = this.achievement1, showsCompletionBanner = true}})
        end
    end
end

function this.login()
    if system.getInfo("targetAppStore") == "apple" then
        gameNetwork.init("gamecenter", gameNetworkListener)
    elseif not this.hasInitialized then
        gameNetwork.init("google", gameNetworkListener)
    else
        gameNetwork.request("login", {userInitiated = true, listener = gameNetworkListener})
    end
end

function this.initialize()
    this.login()
    this.category = "Leaderboard ID" -- Replace this
    this.achievement1 = "Achievement ID" -- Replace this
end

function this.updateHighscore(score)
    gameNetwork.request("setHighScore", {localPlayerScore = {category = this.category, value = score}})
end

return this

Whenever my game starts, I simply require the file and call initialize(). It will prompt the user if necessary, or automatically log them in if they have done so previously.

 

Also, before I post a score or check for an achievement, I make sure that isLoggedIn = true. If not, call login().

            if gameNetwork.isLoggedIn then
                -- Post a score, etc.
            else
                gameNetwork.login()
            end

Hopefully this will help you. :P

 

I use this in my game, Echo Evasion. Check it out! http://www.slatebit.com/echoevasion



[TOPIC: post.html]
#15

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

Mo, will do. Just shout out. I'm not an expert by any means but having gone through it just recently I might be able to recall something that might help. Good luck! 

 

@lKinx, thanks for your awesome sharing! This looks like a great module to serve this need.



[TOPIC: post.html]
#16

LairdGames

[GLOBAL: userInfoPane.html]
LairdGames
  • Pro
  • PipPipPipPipPipPip
  • 960 posts
  • Jedi

LOL, THANKS I will try to start the process as soon as possible so it will be vivid in your mind (if I had went thru that horror, I will never forgotten it :)

 

@IKinx: WOW, superb share!  Even better your app seems to show GC login on my iphone 5 (ios 7+) which with the code I am using would always tells that the user is not log in but it won't show me the login menu. I will try your code and see. Thank you for sharing this. Especially since it seems to work both on Android/iphone!

I quickly checked out your game (and I will leave a review both on amazon and ios...sorry no pure android device) and I am amazed how beautiful it is! Not sure if you are open the suggestions here some. I hope it is ok :)

1- You really need to choose the first screenshot carefully. The menu screen is never a good choice since it is not telling anything. On the iphone, that's the only chance you have to impress. You have a good looking app and you should show it. I will suggest a screenshot with the obstacles showing like when you actually run the game. Also make the screenshot lighter. I know that the theme is a dark cave but for screenshots I think you need to people to see what is going on. I would also explain (banners) what the game is about or its main points. Simply having a normal screenshots does not help sell the game. Menu or about screenshots are not the way to go.

 

2- I will suggest to bring the main character to the center of the screen (or better maybe a little out center to the left) Currently it is really hard to play the game since your hand hides the hero most of the time. So having the hero totally on the left of the screen is not ideal to me.

 

3- I will make the game over menu box (and buttons) MUCH bigger. I had hard time clicking on play again button because it is so small on the iphone 5.

 

4- I do not know how you feel about re-skin but I will STRONGLY suggest you make a re-skin with "flappy bird" type gameplay. Please note, I am not saying to make a bird game but use the same beautiful graphics but make the gameplay the same a flappy bird (so the little guy jump up when you tap and had to go between obstacles...almost of what you have already) Why make a remake?

 

a- Because of the craziness over Flappy Bird, you probably going to get more DL and more exposure.

b- Your version will be the best looking flappy bird type out there. Just look around and you will see what I mean :)

 

PLEASE take these suggestions with a big grain of salt and THANK YOU for you nice code share. I appreciate it!

 

Mo



[TOPIC: post.html]
#17

Buckshi

[GLOBAL: userInfoPane.html]
Buckshi
  • Pro
  • PipPipPipPipPipPip
  • 50 posts
  • Jedi

Hello, 

 

I am having difficulty in getting the SHA1 fingerprint of the certificate. I am following instructions on (https://developers.google.com/games/services/console/enabling) but I am still not being able to get the "c" part (in the link) done i.e, to get the release certificate fingerprint and to get the debug certificate fingerprint. 

 

Thanks



[TOPIC: post.html]
#18

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

Are you on a Mac or PC? Do you have the ADT Kit installed on your computer?



[TOPIC: post.html]
#19

Buckshi

[GLOBAL: userInfoPane.html]
Buckshi
  • Pro
  • PipPipPipPipPipPip
  • 50 posts
  • Jedi

I'm using a Mac.. And I haven't installed the ADT kit yet.

[TOPIC: post.html]
#20

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

Ok. Suggest installing ADT as it gives you the Debug SHA in a Prefs screen. 

 

Did you try the Keytool and have trouble with it? Please review this Corona doc which I found quite useful : 

 

http://docs.coronalabs.com/guide/distribution/androidBuild/index.html



[TOPIC: post.html]
#21

Buckshi

[GLOBAL: userInfoPane.html]
Buckshi
  • Pro
  • PipPipPipPipPipPip
  • 50 posts
  • Jedi

Yes, i tried the keytool but I wasn't able to SHA1 fingerprint of the certificate.. I tried entering the commands suggested by (https://developers.google.com/games/services/console/enabling) in the terminal but I am not getting it.



[TOPIC: post.html]
#22

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

some more insight here : http://developer.android.com/tools/publishing/app-signing.html

 

Basically here is what I did 

 

Using finder I created a folder called Keystore at the root of my user folder. 

Go to Terminal . it will read something like : MachineName-MacBook-Air:~ username$ 

type "cd Keystore" (without the " "). You should now be seeing something like MachineName-MacBook-Air:Keystore username$ 

 

There first run the following to create Keystore : 

 

keytool -genkey -v -keystore yourappname.keystore -alias yourappname -keyalg RSA -validity 999999

 

Make sure to copy this line to Textedit first and edit it there to fix yourappname.keystore and yourappname

 

Once ready take your edited command and paste it into your terminal 

 

You will be prompted with your Mac user password and then a series of questions. Go through these and your keystore will be ready. 

 

Next step is to generate the SHA1 from it. Let me know when you complete the above steps and I'll write more. Hope this helps.



[TOPIC: post.html]
#23

Buckshi

[GLOBAL: userInfoPane.html]
Buckshi
  • Pro
  • PipPipPipPipPipPip
  • 50 posts
  • Jedi

I managed to generate the keystone already but I couldn't do the stuff after this. 



[TOPIC: post.html]
#24

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Pro
  • PipPipPipPipPipPip
  • 2,715 posts
  • Jedi

Great! So then all you have to do is to run the following while your terminal is still inside the Keystore folder : 

 

keytool -exportcert -alias yourappname -keystore yourappname.keystore -list -v



[TOPIC: post.html]
#25

Buckshi

[GLOBAL: userInfoPane.html]
Buckshi
  • Pro
  • PipPipPipPipPipPip
  • 50 posts
  • Jedi

keytool error: java.lang.Exception: Alias <MyApp> does not exist

 

I got this error while trying 




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]