WebStorage vs save/load - which is best for me

Get help using Construct 2

Post » Wed Sep 11, 2013 10:10 pm

I'm making a simple platformer with a level select screen (think angry birds etc - finishing one level will unlock the next. I followed this excellent tutorial: https://www.scirra.com/tutorials/311/level-select).

So when the user closes the browser, I want the level progress to be saved. I've seen tutorials about web storage in C2, and have implemented this for a single variable. But I actually want to save an array, because I want to save whether the user got 1/2/3 stars on each level.

So I looked into saving arrays into web storage, and found this example: http://www.jargogle.co.uk/test/ArraySavingLoading/ (thread here) ...which seems a bit complicated.

I also discovered the save/load feature in C2. Should I be using that instead? Or is it overkill for my simple game?

Are there any benefits & differences between using webstorage vs save/load? onion2013-09-11 22:11:49
B
12
S
2
G
3
Posts: 86
Reputation: 2,960

Post » Wed Sep 11, 2013 11:51 pm

Saving an array to webstorage is easy. Just set the webstorage value to Array.AsJson. For an example see my post on the second page of that thread you linked ;)
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Thu Sep 12, 2013 8:01 am

OMG that's a much simpler solution - thanks so much @ramones, I'm in your debt!

I've just tried this on my project and it works perfectly :-)
B
12
S
2
G
3
Posts: 86
Reputation: 2,960

Post » Thu Sep 12, 2013 9:07 am

Just a comment on your question about the difference.

The difference is that save/load saves the entire state of your game, but webstorage only saves what you tell it to.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, NN81, unicornspitfire and 21 guests