How do I save highscore list?

0 favourites
  • 6 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • Hello everyone.

    I created a top ten highscore layout using arrays. Now my problem is that every time I leave the game on my phone the entire list is gone.

    I tried to use local storage to achieve that but it didn't work. I used "Set Array to Array". Then when I enter the layout with the scores I've done "On start of layout - Set "Array" to Localstorage.itemvalue"

    Does anyboday have an idea?

  • Question: Are you saving as a JSON string?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried to use local storage to achieve that but it didn't work. I used "Set Array to Array". Then when I enter the layout with the scores I've done "On start of layout - Set "Array" to Localstorage.itemvalue"

    Here is how I save and load an array:

    The save event (lets say click "save" button) triggers the following actions to save High Scores array (we'll call this "hscore":

    Object Local Storage: Set item "hscore_key" to hscore.AsJSON

    On Layout Start:

    Object Local Storage On item "hscore_key" exists: Get item "hscore_key"

    Object Local Storage on item "hscore_key" get: Object hscore (the array) Load from JSON string LocalStorage.ItemValue

  • > I tried to use local storage to achieve that but it didn't work. I used "Set Array to Array". Then when I enter the layout with the scores I've done "On start of layout - Set "Array" to Localstorage.itemvalue"

    >

    >

    Here is how I save and load an array:

    The save event (lets say click "save" button) triggers the following actions to save High Scores array (we'll call this "hscore":

    Object Local Storage: Set item "hscore_key" to hscore.AsJSON

    On Layout Start:

    Object Local Storage On item "hscore_key" exists: Get item "hscore_key"

    Object Local Storage on item "hscore_key" get: Object hscore (the array) Load from JSON string LocalStorage.ItemValue

    I'll have to test this on my phone. It doesn't work in the construct 2 preview but I think it doesn't save any game progress and deletes everything after I close the browser.

  • I'll have to test this on my phone. It doesn't work in the construct 2 preview but I think it doesn't save any game progress and deletes everything after I close the browser.

    Interesting, I haven't tested it on mobile so sorry I can't help you from here. Hopefully someone with more mobile experience will chime in soon.

  • > I'll have to test this on my phone. It doesn't work in the construct 2 preview but I think it doesn't save any game progress and deletes everything after I close the browser.

    >

    Interesting, I haven't tested it on mobile so sorry I can't help you from here. Hopefully someone with more mobile experience will chime in soon.

    Didn't work. I probably did something wrong.

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