How do I make a loop to pull keys/values from local storage and assign them to instance variables ?

0 favourites
  • 3 posts
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • I have been trying to do this with different ways with no success.

    I want to create a "Level progress " layout for the game, with the number of stars player received next to each completed level.(see image)

    When the player complete a level, he will receive stars. This data will be saved in local storage in below format

    key - Value

    level number - number of stars received

    When player go to "Level progress" all the completed levels will be shown with number of stars as a sprite next to it.

    for this I need to pull data from local storage and assign the value to a instance variable of corresponding sprite.

    How do I do this ?

  • I would recommend storing the values in a dictionary, then placing it into a singular local storage entry with the dictionary.AsJSON expression. This allows you to store other things in local storage, and index your information easier.

    You might want to consider if you want to store other information about the level ( score, time, etc. ) in which case you might be better off using the JSON or Array plugin instead. Again storing it in local storage by converting it to 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
  • That sounds good I will give it a try and come back here. Thank you :)

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