Help me to display a high score <3

  • Hello guys!

    I've now published my infinite runner "Kuatia" on Google Play Store (check it out here: https://play.google.com/store/apps/details?id=com.bds.kuatia)

    I want to add a high score feature that shows the player their highest score at the end of their run, though. I already have one in place that shows the score for the current run.

    But I want to display their best, too. I'm using the LocalStorage plugin but I can't seem to get it to display.

    I've read the tutorials but I get lost when it's time to replace the HighScore value with the current value if it's higher. I can't get anything to display What am I doing wrong?

    Attached is a screenshot of my events.

    high res image hosting

    Any help is appreciated <3

  • PS: I have TotalDistance and HighScore as global variables in my main game layout. This is my game over layout.

  • Can nobody help?

    Give your boyo a hand! It really is quite a good little game, and I have really tried to implement it on my own.

  • Hmm, so the problem is: You want to change the highscore if it is higher than the previous value.

    Well, that's quite simple.

    I don't know how does your game work, but let's say at the end of the run you calculate the Highscore. Simply add a condition to check if the current score is higher than the last one.

    I can see you already have this event but it needs to be at the end of the run when you calculate the highscore. In the same event, save the Highscore value in LocalStorage.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • RobertMKD, what I'm trying to do is display both current score (which I already have working) and high score (which is saved to LocalStorage). And then compare current score with high score to see if it's higher, and if it is, then update the high score.

    I can now post links so here's my capx file: https://www.mediafire.com/?rez44b8mhmtyd6f

    Any help is appreciated <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Okay, so I have found several mistakes.

    First, you were checking for the LocalStorage data at the start of the "Game Over" layout. The data from LocalStorage is best to be updated at the start of the game (the first layout):

    Second, here you were setting the "high_score" item to a string "TotalDistance", I've done this:

    Third, you are reseting ALL global variables, including the high score, at the start of the "Game" layout. That way, you are actually erasing the highscore data which you need to display later.

    Instead of reseting all global variables, simply return back to 0 those that must be reseted, as an example I have set CurrentDistance to 0, but I guess there's more that need to be reseted:

    So, here's what I've got now:

    30 is the highscore, while 24 is my new score..

    Hope this helped

    edit: in the first image, the 'on item missing' event is not really necessary, so delete it..

  • RobertMKD, that's AWESOME! Thank you! Is there any chance that you could provide me with this modified capx file? I know I'd be copying off your work a little bit, but it'd save me some time (while I work on my day job xD).

    Much appreciated either way! <3 Thanks!

  • Sure, you can download it from here https://www.dropbox.com/s/3iicak6lvxz4w1m/kuatia_for_testing.capx?dl=0

    By the way, it's a nice design you've got there

  • RobertMKD thank you very much, man! And thank you for the comment on the design. I worked hard on it Good to know it's appreciated.

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