Creating a Local Leaderboard

1 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I know this is a pretty archaic feature as we have online leaderboards that can be utilized via a whole host of methods, but there isn't much talk about this that I can find. Some of the answers I did find were using older methods/functions that aren't used anymore, so being newer, it was hard for me to follow.

    What I'm attempting to do is create a local leaderboard that will save and slot a score up to ten local high scores if for some reason the player isn't online/doesn't want to integrate with Google Play/Game Center. Once the 11th score is achieved, it will replace the lowest score on the board in favor of that score, and finally, will sort them from highest to lowest.

    Where I've gotten in my research is using a few different plugins to make this happen. I have an array called LocalLeaderbaord, the AJAX function for calling that information, and a LocalLeaderbooard.json where the scores are stored. AJAX requests the .json data, the array loads it from the AJAX call, and then I load that data into a Text box.

    However, when I load the data with "Set text to LocalLeaderboard.At(0,0)" or any set of coordinates there, I end up only loading that one cell. That's exactly what it's supposed to do, but it seems really redundant to create 33 text boxes that house one cell of data at a time. I just wanted to make sure before I put in the effort to do that, there wasn't a better way to call this information so that the full array is showing at any one time.

    If not, totally okay, but I realize my lack of experience could make me do something for an hour when it could have been done in ten minutes. :)

    -EDIT- Well, I got a little MORE data, but not enough yet. Using "Set text to LocalLeaderboard.JoinString(" ")" returns the whole first row, so we're making progress. Now I only have to make 11 boxes, and not 33.

  • You should look into loops perhaps. Arrays have a foreach-loop. You can loop through and append the text in the textbox each loop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just want to close the loop here (no pun intended) and share some code, in case someone else was looking to do the same thing. I ended up using HTML to draw the table, CSS to format it, and a loop to generate the scores.

    The HTML element within the layout.

    The code blocks.

    The array.

    The CSS (I'm awful with CSS so there's probably a million ways to do this better)

    The output in game.

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