> 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?