LocalStorage does not save data on phone

Get help using Construct 2

Post » Thu Jun 22, 2017 4:41 pm

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.
Like:
Check item exists> On item exists>Get item>On item get.............

What may the problem be?
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Thu Jun 22, 2017 5:22 pm

How did you build the game? Are you testing on iOS or Android?
B
74
S
52
G
62
Posts: 406
Reputation: 39,080

Post » Thu Jun 22, 2017 6:03 pm

Oh sorry, I forgot to mention that.
I have built it using Intel XDK and tested it on Android..
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Fri Jun 23, 2017 3:23 am

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?
B
74
S
52
G
62
Posts: 406
Reputation: 39,080

Post » Fri Jun 23, 2017 12:53 pm

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:

Image
Image

All other items are loaded in the same way..
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Fri Jun 23, 2017 3:49 pm

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.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Fri Jun 23, 2017 4:04 pm

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..
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Fri Jun 23, 2017 5:25 pm

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.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Post » Fri Jun 23, 2017 5:39 pm

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.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Fri Jun 23, 2017 5:45 pm

Loading from the browser is not a valid test for a phone. The phone may take longer. Give my suggestion a try.
ImageImageImage
B
71
S
22
G
259
Posts: 3,794
Reputation: 143,704

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests