How do I Highscore template auto-runner

0 favourites
From the Asset Store
Fruit Slicer Template & Quality fruit and slice graphics (capx,c3p,png,illustrator files)
  • Hi guys im tryting to add a highscore to the template auto-runner so i added a new textbox in the middle called BestDistanceDisplay.

    When the player died i set to the bestdistancedisplay textbox the text of totaldistance, but then all the global variables goes to default and the layout is restarted, same thing happen with the text inside bestdistancedisplay.

    So, mi question is... how can i maintain the value in bestdistancedisplay textbox for every game?

  • As Joskin pointed out you can use webstorage. You can also use the savegame system if you don't want to mess with webstorage. There are many options. It just depends on what you want to store/

  • Thanks for the help Joskin.

    I added the webstorage and the variable always resets, what i'm doing wrong?

    could be the reset of flobal variables or the restart layout?

    Thanks for your help

  • One thing I notice is that it isn't comparing if the TotalDistance beat the BestDistance. It automatically set the bestDistance with the TotalDistance. So regardless if they beat it or not the TotalDistance overwrite the BestDistance.

    The only problem with the Webstorage is that it isn't consistant if you wanted it to be a webgame. The best way someone explained it to me is Webstorage is kind like cookies. So for me it didn't work as planned being that I wanted to host the game on my webspace and people can play and try to beat each other score. But it doesn't work that way. I was told to integrate

  • Also why isn't it Italicized here??


  • I see it now. You are just putting the value of the webstorage back into itself its suppose to be set Local key BestDistance to global variable BestDistance.

  • Not every game needs a webspace based score system. I also see the issue in the missing part of checking if the new score is higher than the highscore.

  • Yea I was just stating in case that they were heading that route and be like me and be like...umm its not working how I intended. Best to know now then develop and find out later. So if that is what they are planning to do they already know.

  • like this? is still not working

  • Set BestDistance to WebStorage.LocalValue("BestDistance")  [/code:1e07swc4]
    [code:1e07swc4]Set local key WebStorage.LocalValue("BestDistance") to BestDistance  [/code:1e07swc4]
    Don't forget the quotes.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I put the quotes but is still doing the same, for an instant the BestDistance is set to the totaldistance but then is reseted again to 0.

    Could be Reset global variables to default and restart layout the problem with this? i saw in a tutorial that sais, on start of layout, set time scale to 1.0... could be this the solution?

  • Is it possible to see the rest of the code to see what is going on?? Everything looks right now. Let us see how you are tallying up the distance.

  • Sure, its the same template auto runner is in the construct File>New.

  • Okay I loaded up and it worked for me you might what to make sure the text box is large enough cause if not it won't display correctly.



    Also make sure you round up when you store the value. I forgot to do that.

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