Having trouble with webstorage for json array vs variables

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi guys,

    I will need to save data into an array as a json file because there will be possibly over a thousand data to be stored, so saving as individual variables might not be the way to go. However, I am having problem in that when I save the array and load it, it works fine as I move between layouts, or restart the game using a restart button inside the game. However, when I exit the game and than run it again, the data is not available anymore. I made a capx below.


    Please run the "main" layout. Press on the play button and it will bring you to another layout. Press any of the blue boxes to increase the value. The values for button 1 and 2 are being saved to an array and stored to webstorage as a json file. The third one is saved using normal webstorage. Switching between layouts or restarting by pressing the green button in the main layout shows everything works fine. But when you exit and restart, only the third one saved with normal webstorage is displayed correctly.

    I am sure I must be doing something wrong, could anyone please help point out what I am doing wrong?

    Also out of curiosity, does the amount of data stored and being saved and retrieved affect the performance of the game? For example, 10 000 individual webstorage key for a mobile game, will there be a noticeable effect on performance?

    Thanks everyone!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On start of layout, rather than load the array from string "A" (which is undefined) you need to load as json from WebStorage.LocalValue("A").

  • Colludium, thank you so much, that was indeed the issue.

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