Adding a Leaderboards Screen
In 'Event Sheet 1' of the 'Ghost Shooter' project, locate event row 9. It's where the game ends and the game over screen is created (by setting the text field to visible).
Our leaderboards screen is going to be quite a bit more complicated than just showing some 'game over' text, so let's create it in a new layout to make things easy for ourselves.
Create a new Layout & Event Sheet called 'Leaderboards', and change the actions so that it goes to the new layout upon death.
On this new Leaderboards layout, draw the screen however you want it to look. Here's what mine looks like:
However there's some very important things I did on this layout that you can't see from just the picture...
I only created 1 row because we are going to use that row to automatically create the other 9 using some simple Construct 2 events. For this to work, you need to make each leaderboard row a different text field, and then add the instance variable called 'row' to them and set it to 1.
Then I also made 'Your Score: XXXX' a new text field with its own name so that we can easily update it with the player's score in Construct 2.
With this setup updating the screen when the player reaches it is easy.
First we update the player score text using the 'Score' variable. We can access it because it is global (shared across all event sheets).
Followed by a for loop, to go from row 2 to the last one and create the text fields along the way. The row variable is very important to set because we will use it again later to know which row should show which score.
And now if you run your project, and reach the game over screen, you should see the leaderboard with all 10 rows:
And that's the screen created! Now we just need to download and upload scores to fill it in.