How do I save highscore on the device in a auto runner game?

0 favourites
  • 6 posts
From the Asset Store
A futuristic device, can be used as radarscreen, optionscreen, infodisplay, research device, ...
  • I have been working with the "Template-AutoRunner", that comes with c2. I want to store the score locally to the device. I saw many tutorials about using the local storage , but non-of these worked with auto runner

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you are running it in a browser you can use save and load in the systems commands and that will save your score and where you stopped playing and that data can be used when you load the game for other purposes.

    If you are using an NW.js game then someone else will have to help you with local storage as that is not something I have played around with much?

  • I have been working with the "Template-AutoRunner", that comes with c2. I want to store the score locally to the device. I saw many tutorials about using the local storage , but non-of these worked with auto runner

    I'm working on an auto-runner and save the High Score locally using local storage.

    Add the LocalStorage object

    Add global variables Score=0 and HighScore=0

    Initialise your high score:

    System: On start of layout

    -> LocalStorage: Get item "HighScore"

    LocalStorage: On item "HighScore" get

    -> System: Set HighScore to int(LocalStorage.ItemValue)

    In your level end event (where you'd show the high score and have a restart button), add a sub-event:

    System: Compare Score > HighScore

    -> System: Set HighScore = Score

    -> LocalStorage: Set item "HighScore" to HighScore

  • > I have been working with the "Template-AutoRunner", that comes with c2. I want to store the score locally to the device. I saw many tutorials about using the local storage , but non-of these worked with auto runner

    >

    I'm working on an auto-runner and save the High Score locally using local storage.

    Add the LocalStorage object

    Add global variables Score=0 and HighScore=0

    Initialise your high score:

    System: On start of layout

    -> LocalStorage: Get item "HighScore"

    LocalStorage: On item "HighScore" get

    -> System: Set HighScore to int(LocalStorage.ItemValue)

    In your level end event (where you'd show the high score and have a restart button), add a sub-event:

    System: Compare Score > HighScore

    -> System: Set HighScore = Score

    -> LocalStorage: Set item "HighScore" to HighScore

    I have a question on that:

    If the get returns nothing will it just put zero in the high score or do you need to check first if "highscore" has a value in it?

  • If the get returns nothing will it just put zero in the high score or do you need to check first if "highscore" has a value in it?

    I believe it will return 0 if there is nothing there, same as if you use the ItemValue outside of the On Get event.

    At least, that's how it seems to work in my game.

  • > If the get returns nothing will it just put zero in the high score or do you need to check first if "highscore" has a value in it?

    >

    I believe it will return 0 if there is nothing there, same as if you use the ItemValue outside of the On Get event.

    At least, that's how it seems to work in my game.

    Ok thanks I will give it a try.

    I think that is what kept it from working for me as I was checking the value and nothing there to check.

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