LocalStorage does not save data on phone

0 favourites
  • 12 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I have installed my game on my phone in order to test it out, but I have noticed that my progress does not save.

    I am sure I have set my events properly.


    Check item exists> On item exists>Get item>On item get.............

    What may the problem be?

  • How did you build the game? Are you testing on iOS or Android?

  • Oh sorry, I forgot to mention that.

    I have built it using Intel XDK and tested it on Android..

  • I can tell you I never had a problem with LocalStorage when using XDK, so I would guess its more likely to be a problem with your events?

    There is a known bug with Cocoon where LocalStorage data is lost on iOS if you are using WebView+.. but as far as I am aware there is no similar problem with XDK, at least I never experienced it.

    Are you saving your data to LocalStorage properly?

  • Yes, LocalStorage saves data properly while in debug mode in browser, while here are part of the events for the updating of data when the game starts:

    All other items are loaded in the same way..

  • It's recommended that you use a dictionary to store many items, so you only need one Set and one Get to get all of your data. Note: the Get is not necessary. If the item exists, you can get it immediately in "On exists". You should also check for "On missing" to set your defaults, or at least to know that the exists-check is done and you can now use the values. Are you holding off using those values further in the code until you know Exists has finished? It can take longer on a slower device.

  • Okay, I will use a dictionary as you said, but will that solve the problem?

    I'm loading this data at the start and use it during the game..

  • Again, are your events organized to only read them after you know for sure they have been loaded?

    It's certainly easier to see if they loaded or not; just add a text object and populate with the JSON data to confirm the load on the mobile unit. Once you've confirmed that, if things don't "work", you know the issue is something else.

  • I have already done that, and the data is successfully loaded when previewing on browser (so it did before I even started using the Dictionary) , but it does not load on phone.

    I found out that the size of the data of the application is increased when I play the game for a while (when I actually save some data on the device), so it looks like there is a problem with the loading on the data when starting the game.

  • Loading from the browser is not a valid test for a phone. The phone may take longer. Give my suggestion a try.

  • I will, after the next build. But if that's the case, how do I measure the time it needs to load?

    Btw, my data is loaded at the first layout which is a preloader one, and takes some time to load until it finishes loading and turns the next layout on.

    So, is the loading of data from LocalStorage included in this loading of the preloader layout?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LocalStorage has nothing to do with preloader. Just make sure you can not move to the next layout until Exists comes back with yes or no. After that, you are good to go.

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