How Make It So if You Make Leaderboards

How to Create and Use a Leaderboard

In this tutorial, we follow an example of how to create and apply a Leaderboard. Nosotros'll:

  • Create an Event with an Attribute that nosotros can use every bit a Running Full for our Leaderboard and which we'll apply to log player scores against the Leaderboard.
  • Create a Leaderboard that will human activity as a loftier score table by arranging all the players' scores from highest to lowest.
  • Lastly, test the configuration in the Test Harness.

Creating an Upshot

In this section we'll use the Configurator to create an Event with an Aspect that becomes a Organisation Generated Running Full - this allows your game lawmaking to post histrion scores into the GameSparks platform and have the platform store the highest score for each player.

1. Get to Configurator > Events.

2. Click to Add a new Event. The Add Effect folio opens.

3. Enter the details for the new Result:

four. In the Attributes console, click to Add together a new Aspect to the Event.

five. At present fill in the Event Attribute details:

  • Short Code - This volition be used every bit the key for the score that you post into the platform from your game code.
  • Name - The Name of the Attribute - recall that one Event can accept several Attributes.
  • Data Blazon - Gear up this to Number in the instance of a high score table because the incoming scores are integers and nosotros want to be able to sort them into numerical society.
  • Default Value - For our example, you can exit this blank.
  • Default Assemblage Blazon - In the example of a high score tabular array, we desire to track the highest score posted past each of the game's players. Hence, we select Maximum for the default aggregation method. This volition upshot in one record per actor been stored in the GameSparks platform and that record volition incorporate the player'due south highest score.

Event Attributes as Running Totals? Leaderboards are driven by Running Totals. Any Events that you create with an Attribute which doesn't accept Default Assemblage Blazon ready to Used in Script become System Generated Running Full and will appear for selection as a Running Total when you configure a Leaderboard. (You lot tin learn more than about Running Totals here.)

half-dozen. Click to Relieve and Close the new Event.

Creating a Leaderboard

In this department we'll create a Leaderboard which arranges all the players' scores in lodge from highest to lowest.

1. Start by going to Configurator > Leaderboards.

2. Click to Add a new Leaderboard. The Add Leaderboard page opens:

3. Enter the Leaderboard details:

  • Short Code - A mandatory field which will be used when your game posts scores into the GameSparks platform.
  • Name - Mandatory field for name of the Leaderboard.
  • Description - A mandatory field, typically used to describe the Leaderboard's purpose.
  • Team - Leave this at the default of None, which means the Leaderboard is a Histrion type.
  • Update Frequency - Set this to Real Fourth dimension.

Other Configuration Options? For our example, yous can leave the other Leaderboard options at their default settings.

four. In the Fields panel, click to Add a Running Full to the Leaderboard:

5. Now fill up in the Running Full details.

  • Running Full and Collector - These will default to the Aspect you created for the Event in a higher place (or if you take already created other Events you can select Score Consequence and SCORE_EVT.SCORE_ATTR respectively from the drop downs). Note that Running Totals are an advanced topic that nosotros don't need to worry most for this exercise.
  • FilterType - Set to '*' (wildcard) then that all values are included.
  • Filter Value - This is not relevant in this example.
  • Sort - Set to DESC (descending) to guild the Leaderboard from highest player score to everyman.

6. Click to Relieve and Close the new Leaderboard.

IMPORTANT - Leaderboard entries will be lost for updated Leaderboards! If you edit a Leaderboard that has had entries posted to information technology, these entries volition exist lost when you relieve your editing changes and update the Leaderboard's configuration.

Testing the Loftier Score Leaderboard and Consequence in the Examination Harness

In this section we'll:

  • Utilize the Examination Harness to annals some test players with the preview version of the game.
  • Authorize these players and post a score to the Leaderboard for each 1.
  • We'll see the JSON requests and responses too as asynchronous letters generated by the platform.
  • We'll and then query the Leaderboard data in various ways.

Registering Examination Players

1. Get to the Test Harness section and select RegistrationRequest from the Authentication menu and change the userName and displayName as shown below.

2. To send this JSON request to the GameSparks platform, click Send Request. The Inspector shows:

  • The request (in green text) that was sent to the GameSparks platform via the WebSocket.
  • The response (in blue text).

Repeat the registration step for four boosted users.

Authenticating a Test Role player

At present nosotros'll authorize our showtime Role player: player_first.

1. Select the AuthenticationRequest from the Authentication card and modify the userName to player_first as shown below.

ii. To transport this JSON request to the GameSparks platform, click Send Request. The Inspector shows:

  • The asking (in green text) that was sent to the GameSparks platform via the WebSocket.
  • The response (in blue text).

Posting a Score to the Leaderboard

1. To log a score for our kickoff Player, under Requests click Log Event then select SCORE_EVT - this is the Event yous created above. Discover that the Curt Code of the Result Attribute that we chose before, SCORE_ATTR, has been inserted every bit one of the keys in the JSON request.

2. Change the value to 110 as shown and click Send Request. This will register a score of 110 for the commencement Histrion:

Annotation that too as the request and response shown in the Inspector that there is too an asynchronous NewHighScoreMessage (in yellow text):

  • This message includes the score posted too as the global rank details.
  • Every time a player beats their previous best they will receive a message of this blazon.
  • If the starting time Player logs another score that is ten or less they will not receive a NewHighScoreMessage.

iii. At present repeat the Authorization and Log Result step for the other four users that yous registered. Use an increasing score for each user, for example, 210 for the 2nd Actor, 310 for the third Player, so on.

Retrieving Leaderboard Data

i. To view the Leaderboard, select LeaderboardDataRequest from the Leaderboards menu.

2. Change the leaderboardShortCode in the JSON asking to HIGH_SCORE_LB, which is the Short Code that yous used when you created the Leaderboard:

3. Click Ship Request. The response message can be seen in the Inspector and should incorporate entries for all 5 users that you logged Score Events for in the previous steps along with their ranks.

To control the number of entries returned by the LeaderBoardDataRequest, ready the entryCount field to the required value. Besides, to view a different role of the Leaderboard, set the offset field. The starting time is relative to the top-ranked position in the Leaderboard.

  • In the current example, player_fifth is our top-ranked player with a score of 510 which represents: beginning=0. So the response for this request, where offset=3, will return 210, that is, the score of the player ranked 4th on the Leaderboard.

If the current authorized histrion was linked to their Facebook account in the GameSparks platform and they had friends who had logged scores in this game, then setting the social field value to true would return Leaderboard data containing just the player and player's friends:

Getting Players "Around Me"

1. Authenticate the 3rd Player (get to Hallmark > AuthenticationRequest and then change the userName in the JSON asking to Third Actor).

ii. Next, under Requests click Leaderboards and and then select AroundMeLeaderboardRequest.

3. In the JSON request, set the count field to i to testify the Leaderboard entries either side of the tertiary Player (the currently authorized player). Notice that the player's rank and score are included in the response:

If y'all were to authenticate the first Player and echo the AroundMeLeaderboardRequest, the response would only include two entries. This is considering the offset Player is at the lesser of the Leaderboard so only the player one rank college than this Player is shown in the response.

wolfnortenathe.blogspot.com

Source: https://docs.gamesparks.com/tutorials/social-features/creating-a-leaderboard.html

0 Response to "How Make It So if You Make Leaderboards"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel