How do I create a top 10 highscore list?

Get help using Construct 2

Post » Wed Apr 05, 2017 8:49 pm

Hey everyone.

I was able to create a score and now I want to have a Layout where the player can see a List of the 10 best scores he has made in the game.
B
14
S
3
Posts: 50
Reputation: 907

Post » Thu Apr 06, 2017 4:26 am

I assume this is for single player offline and not via scirra arcade.

You will need to learn how to use local storage first, it is not too complex.
You will need a variable to store in local storage that tracks how many times player "won" and increments each time by one... ie. timesScored=0.. (win) timesScored=1.
You will then need to make a variable for each score you want stored. You can use global variables for this or make a global sprite "brain" with instance variable inside (1 for each score stored).

In your win (or scored) events you will need to condition out timesScored=0 TextScore1 set text "Score: "&Score1var... etc

If you want incremental (highs to lowest) you will need to use conditions prior to displaying to check if score1 is > score2 etc.

Or for advanced users, store them in an array.. or even dictionary.. or.. many ways..
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
70
S
19
G
8
Posts: 639
Reputation: 9,674

Post » Thu Apr 06, 2017 1:49 pm

chrisinfinger wrote:I assume this is for single player offline and not via scirra arcade.

You will need to learn how to use local storage first, it is not too complex.
You will need a variable to store in local storage that tracks how many times player "won" and increments each time by one... ie. timesScored=0.. (win) timesScored=1.
You will then need to make a variable for each score you want stored. You can use global variables for this or make a global sprite "brain" with instance variable inside (1 for each score stored).

In your win (or scored) events you will need to condition out timesScored=0 TextScore1 set text "Score: "&Score1var... etc

If you want incremental (highs to lowest) you will need to use conditions prior to displaying to check if score1 is > score2 etc.

Or for advanced users, store them in an array.. or even dictionary.. or.. many ways..


Do you know any tutorial that might help me?

Found this but it's not up to date.
https://www.youtube.com/watch?v=z_Z5rGSZnCo&t=393s
B
14
S
3
Posts: 50
Reputation: 907

Post » Thu Apr 06, 2017 1:58 pm

Good local storage tutorial. It is the part the other tutorial seems to be out of date on (it's using old webstorage).
https://www.scirra.com/tutorials/1461/how-to-use-the-localstorage-plugin
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
70
S
19
G
8
Posts: 639
Reputation: 9,674

Post » Thu Apr 06, 2017 2:06 pm

chrisinfinger wrote:Good local storage tutorial. It is the part the other tutorial seems to be out of date on (it's using old webstorage).
https://www.scirra.com/tutorials/1461/how-to-use-the-localstorage-plugin


Will I need to work with arrays too?
B
14
S
3
Posts: 50
Reputation: 907

Post » Thu Apr 06, 2017 2:13 pm

Arrays would be the much cleaner and shorter code way to do it.. and you will only help yourself by learning them.

You can do it using just variable as I pointed out above but your code will be 3x as long.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
70
S
19
G
8
Posts: 639
Reputation: 9,674

Post » Thu Apr 06, 2017 3:00 pm

chrisinfinger wrote:Arrays would be the much cleaner and shorter code way to do it.. and you will only help yourself by learning them.

You can do it using just variable as I pointed out above but your code will be 3x as long.


I've read an explanation aboutthem but didn't really understand it. Have to give it another try.
B
14
S
3
Posts: 50
Reputation: 907


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], DrKoala, irina, zenox98 and 25 guests