Store persistent data with CocoonJS

Get help using Construct 2

Post » Wed Jul 18, 2012 6:27 pm

Hey guys

I have tried to see if there are any examples, or samples, or documentation about the cocoonjs and local storage. But to no avail.

If I go look at the feature list all that they have is the following for localStorage:

Standard functions
- clear
- getItem
- key
- removeItem
- setItem
Standard properties
- length

http://wiki.ludei.com/cocoonjs:featurelist

I am unsure if this is going to remain on the device after the game has closed, or if anyone has another or better way to save device specific game data?

Knowing the guys at Ludei and Scirra, this could be in development for the next build.
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Wed Jul 18, 2012 7:25 pm

Ooh, I'd like to know this too. Haven't come to this part in the program yet, but it's always good to know.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Thu Jul 19, 2012 12:25 am

Have you tried it? Just add the Webstorage object and store something in local storage.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Jul 19, 2012 7:41 am

http://www.scirra.com/tutorials/303/how-to-export-to-cocoonjs/page-1

This tutorial covers a lot of important imformation about exporting to Cocoonjs, but it might not be updated every time Construct updates.

If WebStorage doesn't work for you, the Dictionary feature may be a nice substitute.
B
19
S
5
G
1
Posts: 104
Reputation: 2,920

Post » Thu Jul 19, 2012 12:59 pm

@Ash, will give it a try. Thanks.
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Sat Jul 21, 2012 3:21 pm

I added the local storage object and tested it out with cocoonJS. Works perfectly.
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Mon Jul 30, 2012 10:30 pm

Hello @superkew i using webstorage and my game for cocoonJS have this events but on webstorage. I wonder how looks like events created to LocalStorage?
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

Post » Tue Jul 31, 2012 10:51 am

Using WebStorage

The WebStorage object uses a very simple storage model: values are stored under named keys, similar to how the Dictionary object works. For example, the value 100 could be stored for the key score with the action Set local value "score" to 100. Similarly the value John can be stored for the key name. Then the expression WebStorage.LocalValue("score") returns "100" (as a string) and WebStorage.LocalValue("name") returns "John", and these values persist between sessions. (If session storage was used instead, the values would only last as long as the browser session.)

Note WebStorage only stores strings. If you set a key to a number like 100, when you retrieve it back it will be a string. To convert it back, use the system expression int, e.g. int(WebStorage.LocalValue("score")).

http://www.scirra.com/manual/120/webstorage/page-1
B
22
S
7
G
3
Posts: 189
Reputation: 4,270


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, Yahoo [Bot] and 19 guests