How do I store data in local?

Get help using Construct 2

Post » Tue Sep 12, 2017 7:28 am

Message: tostasifone can only post plain text URLS until they have 500 rep. 3 URLS modified. Why?
Hello, I was developing an android game in which you can collect money.

I followed this guide https://www.scirra.com/tutorials/1461/how-to-use-the-localstorage-plugin


to export my project in an apk file I followed this guide https://www.scirra.com/tutorials/9492/build-android-apps-with-phonegap

I've installed the apk on my device but the local storage doesn't work. When I close the app, the money reset. I'm definitely wrong with something but just can not understand what, please help me.

here is the capx file https://drive.google.com/file/d/0B3kb9LVUfy7yWkVfbWxJWFU0VUU/view
Last edited by tostasifone on Wed Sep 13, 2017 7:32 am, edited 1 time in total.
B
9
Posts: 11
Reputation: 351

Post » Wed Sep 13, 2017 7:05 am

No one can help me?
B
9
Posts: 11
Reputation: 351

Post » Wed Sep 13, 2017 7:28 am

Your links are broken, post them in clear text or as Code.
Check out my awesome game Doptrix
B
17
S
9
G
30
Posts: 527
Reputation: 17,353

Post » Wed Sep 13, 2017 7:35 am

Oh sorry, I forgot that my links are hidden.
B
9
Posts: 11
Reputation: 351

Post » Wed Sep 13, 2017 9:58 am

Hi @tostasifone

I'll check your capx file at home. I'm currently at work and have no access to c2.

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
100
S
35
G
30
Posts: 1,137
Reputation: 28,087

Post » Wed Sep 13, 2017 12:27 pm

@tostasifone
I haven't implemented local storage yet in my game, but even I see that you are doing it all wrong. There is a dozen of mistakes in your file...
You shouldn't read or write to storage on every tick! This is a time consuming operation and you need to follow the rules.
You get item once on start of layout for example, then you wait for it to be retrieved (LocalStorage->On item get). If it's missing, then you create this item.
When your money amount is changed, you set item. You should do it only once, not on every tick! And then you may want to wait and check that it was saved successfully (LocalStorage->On item set).
You should definitely study the tutorials.
Check out my awesome game Doptrix
B
17
S
9
G
30
Posts: 527
Reputation: 17,353

Post » Wed Sep 13, 2017 2:07 pm

Message: tostasifone can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@dop2000 You are right, I've uploaded the wrong file on my google drive.
Here is the correct capx https://drive.google.com/open?id=0B3kb9LVUfy7yT01zTG8zdlc5MWc
Sorry, I'm so heedless...
B
9
Posts: 11
Reputation: 351

Post » Wed Sep 13, 2017 2:56 pm

ImageImageImage
B
71
S
22
G
242
Posts: 3,734
Reputation: 134,994

Post » Thu Sep 14, 2017 6:50 am

@blackhornet
Thank you so much, now I understand how local storage works.
B
9
Posts: 11
Reputation: 351

Post » Fri Sep 15, 2017 11:18 am

tostasifone wrote:@blackhornet
Thank you so much, now I understand how local storage works.


I changed your capx file, please see the comments.
https://drive.google.com/open?id=0Bz4Kp ... HU1MXJNMjA

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
100
S
35
G
30
Posts: 1,137
Reputation: 28,087

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests