How do I create a top 10 highscore list?

  • 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.

  • 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

  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • 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

  • dropbox.com/s/04p6xrlnn57owox/scoretable.capx

    Done. Sir, you are a legend! Thanks a lot!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)