Easily Add Leaderboards to Your Game

Index

Stats

6,065 visits, 17,798 views

Translations

This tutorial hasn't been translated.

Tools

Saving Scores

Let's start off by making a couple small tweaks to the leaderboards screen so player can enter their names before submitting their score.

We want to save the player's score when they press on the submit score button. This is really easy using the 'Save Leaderboard Data' action. Add a mouse-clicked-button condition to your project, followed by a 'Save Leaderboard Data' action by selecting it from the Playtomic plugin.

Fill out the settings dialog that appears. As you can see, I use:

Whatever the player entered in the text box as the player's name

The global variable Score which was created during the beginner's guide tutorial as the number of points

"HighScores" as the leaderboard. You can save scores to different leaderboards by changing the name. For example you could use the level name if you want to save scores to a different leaderboard each level!

The rest of the settings I left at their default values. You can experiment with them in your own project! The leaderboards are pretty flexible and allow you to do a lot of neat things using their settings.

So in total this is what we added to the event sheet to save scores:

As you can see, I also disabled the submit button when the score has been submitted to prevent the player from uploading the same score multiple times! As one last precaution, I'm going to stop the player from submitting some invalid names. You should never trust your player to enter a good name and always check that it is valid!

Now when you run the game, enter a name and click the submit button. Since we're not displaying the scores ingame yet, go to the Playtomic website, select your game, and then Leaderboards. You should see your newly uploaded score in the list.

Fantastic! Now we just need to show the leaderboard in-game and we're done!

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!