How do I create a top 10 highscore list?

Get help using Construct 2

Post » Tue Apr 04, 2017 10:02 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 » Tue Apr 04, 2017 10:31 pm

Look into arrays (they are basically spreadsheets of data) - https://www.scirra.com/manual/108/array

You'll want a 10x1x1 array, one spot for each score.

Upon getting a new score, you can "Push" the new score to the array (now there are 11 values).
Then "Sort" the array so that they are in order highest to lowest.
After that, "Delete" the last element in the array so you are left with the 10 highest scores.

After that, you can display the scores however you wish. A simple single text object example would be as follows-

Set TextObect text to ""
Repeat Array.width times - Append "loopindex&" - "&Array.At(loopindex)&newline" to TextObject
Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643

Post » Wed Apr 05, 2017 3:35 pm

oosyrag wrote:Look into arrays (they are basically spreadsheets of data) - https://www.scirra.com/manual/108/array

You'll want a 10x1x1 array, one spot for each score.

Upon getting a new score, you can "Push" the new score to the array (now there are 11 values).
Then "Sort" the array so that they are in order highest to lowest.
After that, "Delete" the last element in the array so you are left with the 10 highest scores.

After that, you can display the scores however you wish. A simple single text object example would be as follows-

Set TextObect text to ""
Repeat Array.width times - Append "loopindex&" - "&Array.At(loopindex)&newline" to TextObject


Haven't worked with arrays before and don't udnerstand much after reading the manual. Is there any other tutorial that could help me?
B
14
S
3
Posts: 50
Reputation: 907

Post » Wed Apr 05, 2017 5:01 pm

There is actually a plugin that involves steam and then what you could do is link it with the leaderboard that comes with this plugin that goes on the steam website
Image
B
25
S
14
G
12
Posts: 290
Reputation: 9,402

Post » Wed Apr 05, 2017 9:07 pm

Mistakes were made.
B
52
S
26
G
109
Posts: 1,611
Reputation: 61,643

Post » Wed Apr 05, 2017 9:56 pm

I learned arrays by playing around.

Make a new .capx and test this out.
Add array, touch, sprite1, sprite2.
Make your array 3,1,1

Event Sheet
On start of layout:
set value of x 0 to 100 (array, set at x)
set value of x 1 to 400
set value of x 2 to 200

on touch sprite1: sort array
on touch sprite2: reverse array

Then run this in debugger preview (that way you can see how the array changes as you click)

Good Luck
B
11
S
2
Posts: 33
Reputation: 651

Post » Thu Apr 06, 2017 10:22 pm

oosyrag wrote:https://www.dropbox.com/s/04p6xrlnn57owox/scoretable.capx?dl=0


Done. Sir, you are a legend! Thanks a lot!
B
14
S
3
Posts: 50
Reputation: 907


Return to How do I....?

Who is online

Users browsing this forum: PROxMTswatTR and 19 guests