How do I create permanent variables

Get help using Construct 2

Post » Fri Jun 20, 2014 10:46 pm

Hi. I'm finisihing my first project but there's something I want to implement but haven't really been able to figure out how to do it using Construct features.

I want to publish my app to the android market. I'm trying to create a variable that the game will load every time it starts, and it's not restarted even after the game was closed, phone turned off, etc. If the player dies 20 times in one play, closes the app, starts playing again and the deadths counter loads that variable and shows that he has already died 20 times.

I tried using webstorage but doesn't really seem to work. I'm using clay.io for leaderboards and achievements and I saw there's some kind of data storage but, I don't know how to use it, besides the user will need access to internet to be able to fetch that data.

Hope you guys can help me, thanks!
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Fri Jun 20, 2014 10:51 pm

Well, I know you said you already used webstorage but give it another shot. I did it and it worked out really well.
B
37
S
14
G
3
Posts: 263
Reputation: 4,280

Post » Fri Jun 20, 2014 11:02 pm

Ok, I messed up assingning the values at start of the app. Thanks @HZGaming if it wasn't for your help I would have trashed everything about webstorage, you made me look again and find my dumb mistake. :P
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Fri Jun 20, 2014 11:06 pm

No prob. Glad I could help :)
B
37
S
14
G
3
Posts: 263
Reputation: 4,280

Post » Sat Jun 21, 2014 12:25 am

@HZGaming worked on preview but not when exported to crosswalk for Android.

Any help would be appreciated.
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Sat Jun 21, 2014 12:34 am

:/ What was the problem?
B
37
S
14
G
3
Posts: 263
Reputation: 4,280

Post » Sat Jun 21, 2014 3:31 am

@HZGaming ir worked in the preview but not on my phone exported with crosswalk for Android. I will keep trying , but it.doesn't seem to work
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Sat Jun 21, 2014 3:39 am

1. WebStorage means using web based storage tools. Such as cookies. WebStorage although misnamed does not actaully use the internet. The data saved in using WebStorage is actually in the local data app cache. So it works offline.

2. Make sure your using LocalStorage not SessionStorage when saving data between application runs. Session storage means short term. Once the app closes and memory is cleared the data is gone. Where as LocalStorage means the data is stored persistently between app runtimes.

3. Data is stored per device. Any data stored on preview does nto carry over to the device.

If your still having problems include my @name and provide a sample capx of how your using webstorage. Then I can see how your using it. If that fails then I'm not sure. I've never had problems with persistent storage on devices. It's very low level and extremly common plugin and api that all HTML5 game developers use.
B
92
S
18
G
9
Posts: 2,455
Reputation: 15,113

Post » Sat Jun 21, 2014 6:33 am

@jayderyu @HZGaming, finally solved it. Thanks guys, you are awesome.

It seems like it's all good now. I'm having a little problem with sound playing a little late, I've tried changing when the sounds should be played, preloading them, etc.
B
21
S
5
G
3
Posts: 53
Reputation: 3,335

Post » Sat Jun 21, 2014 3:13 pm

You should mostly thank @jayderyu for the webstorage issue but the sound problem you mentioned is, in my opinion, quite common. All my games at some point have random delays in sounds and I haven't found a solution. However, many customers most likely don't play with their sound on, especially if its just for effect.
B
37
S
14
G
3
Posts: 263
Reputation: 4,280

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests