doubts online ranking

0 favourites
  • 12 posts
From the Asset Store
Game rank and league badge creator mega asset pack
  • I did this rating online with firebase

    but i don't know how to make it sort the scores from lowest to lowest

  • Looks like the response from Firebase comes in JSON format. You can load (parse) it into JSON object, then loop through all scores in JSON and copy them into an array. Then sort the array and display sorted values on the leaderboard.

  • Looks like the response from Firebase comes in JSON format. You can load (parse) it into JSON object, then loop through all scores in JSON and copy them into an array. Then sort the array and display sorted values on the leaderboard.

    yes, but i don't know which line of code i use to sort

  • After you copied all values into an array, you can use "Array Sort" action. It will sort by the first column, so make sure that it contains the scores, not names.

  • After you copied all values into an array, you can use "Array Sort" action. It will sort by the first column, so make sure that it contains the scores, not names.

    Yes I understand that you have to copy the data to the array, but how do you load firebase data into the array?

    I can't find any topic, tutorial or video about it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Load into a JSON object. Then use "JSON For each key" loop and insert every value into an empty array. Can't tell you more details because I don't know the format of your JSON data.

    There is an example project in C3 showing how to work with JSON, check it out.

  • Load into a JSON object. Then use "JSON For each key" loop and insert every value into an empty array. Can't tell you more details because I don't know the format of your JSON data.

    There is an example project in C3 showing how to work with JSON, check it out.

    my data is like this

    https://teste-e9ce3-default-rtdb.firebaseio.com/ranking.json

    I looked at the "ghost racer" model but it works with local.storage to load the data, my data is in an online base, I found tutorials that use "webstorage" but I think this function doesn't exist anymore. I tried this and it doesn't load the data

  • Why "ghost racer"?? I meant this example:

    And you can't load your data directly into the C3 array. You need to load (parse) it into JSON object first. Then do something like this:

  • Why "ghost racer"?? I meant this example:

    And you can't load your data directly into the C3 array. You need to load (parse) it into JSON object first. Then do something like this:

    I finally made some progress, I managed to put the data in the array, but this part is now useless, right?

    so the array loads the data all disorganized.. now what?

  • ok dop2000, I managed to put it in order and make it appear on the screen, but why doesn't the names appear?

  • This is a 2-dimentional array. The first column (at Y=0) contains scores, the second column (Y=1) contains names. After sorting, Array.At(0,0) will contain the highest score. Array.At(0,1) will contain the name of the person who made that score.

    Array.At(1,0) - second best score, Array.At(1,1) - its name

    Array.At(2,0) - third best score, Array.At(2,1) - its name

    And you should display the scores in the same event where you parse them (add another sub-event in event #3.

  • This is a 2-dimentional array. The first column (at Y=0) contains scores, the second column (Y=1) contains names. After sorting, Array.At(0,0) will contain the highest score. Array.At(0,1) will contain the name of the person who made that score.

    Array.At(1,0) - second best score, Array.At(1,1) - its name

    Array.At(2,0) - third best score, Array.At(2,1) - its name

    And you should display the scores in the same event where you parse them (add another sub-event in event #3.

    Thanks for the help dop2000 your contributions are always helpful

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