Facebook - Highscore List

Get help using Construct 2

Post » Mon Nov 28, 2011 10:42 am

I've been trying to implement the Facebook object, and its mostly gone smoothly and I'm happy with the way it works, but I've come up against a bit of a wall when it comes to making the highscores list work. At the end of my game, you can submit your score, and it automatically posts a message to your wall saying "I scored X points!" and it works fine.

The bit I can't work out is how to display a list of scores - say, the top 10, for example.

When the 'submit' button is pushed, it also "Requests Highscore board" - but what do I do with this? I'm guessing I need to link this to a text field and display the scores in that, but I can't figure it out.

Has anyone done this successfully yet, and if so, could offer some tips?
Thanks a bunch
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Mon Nov 28, 2011 2:55 pm

'Request hi-score board' just requests the hi-scores - they arrive a moment later. When they arrive, the Facebook object's 'On hi-score' trigger runs once for each hi-score. In this trigger the HiscoreName, HiscoreRank and Score expressions in the Facebook object are set so you can get the current hi-score e.g. "#1 - Tom Gullen - 1337". A simple way to list scores is to append that to a string object in the 'On hi-score' event, so when it triggers for each hi-score you end up with a full list of scores.

Note that if the user is submitting a hi-score, it won't appear in the hi-score board until the 'On score submitted' trigger runs. So you might want something like "On score submitted: request hi-score board" to guarantee the score the user is submitting will appear in the hi-scores.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Mon Nov 28, 2011 5:17 pm

could you upload a example @Ashly.. I tried to implement facebook to, did no go so good.
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Mon Nov 28, 2011 5:32 pm

Thanks for the response Ashley, that helped a lot. I've now successfully got the text field to load up the current user's score, but I can't get it to load up the other users. (to test this, I've got several friends to play and submit scores as well, so there's definitely a few scores being submitted).

I would totally appreciate an example file if you have one too...
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Mon Nov 28, 2011 5:38 pm

@FatRat - you have to use 'append text' and a text object big enough. If you use 'set text' only the last score will be shown, or the size of the text box will cut them off. E.g. a big text object with

+ On hi score
-> Append text Facebook.HiscoreRank & ": " & Facebook.HiscoreName & " - " & Facebook.Score & newline

Does that work? If not I'll see about making an example.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Tue Nov 29, 2011 10:45 am

Aha! Yes, thanks a lot. Using 'Append Text' works. I now have a list of highscores, but they are all showing up as '0' score and in the wrong order, but I think that's something I can fix.
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Tue Nov 29, 2011 11:15 am

@FatRat. Is there any way you could upload your capx, or a example one? This facebook thing is confusing me.. :S
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Nov 29, 2011 11:21 am

Have you gone through the entire Facebook game tutorial on this site first?

http://scirra.com/tutorials/58/how-to-make-a-facebook-game/page-1

Unless you have the game hosted on a secure domain (https://) the Facebook API has very limited functionality. That was the first headache I had when starting on this...
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Tue Nov 29, 2011 11:25 am

Yeah i tried to upload my game onto facebook. I have a server. But as far as a know its not https, how do you get this?
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Nov 29, 2011 11:43 am

I got a certificate from godaddy for about a tenner, but I got a friend to configure it as I don't really know how to set them up. If you have a hosting package, you'll have to look into setting it up on that.
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Next

Return to How do I....?

Who is online

Users browsing this forum: heliogame and 19 guests