How do I autosave without a button?

Get help using Construct 2

Post » Mon Nov 24, 2014 11:47 pm

Hi,

I love the Save&Load functions but I have trouble using them. I would like the levels in my game to stay locked/unlocked whenever the user quits or launches the application without the need for them to press a 'save game' button. Is there a way to do this?

I can't do BOTH auto-load and auto-save using triggers in the menu because it will create a loop or not work as intended. The ideal situation would be to detect a 'on first start of layout' (load) and a 'on game quit' (save) events, but there are no such things. Any ideas?
B
16
S
7
G
1
Posts: 161
Reputation: 3,131

Post » Tue Nov 25, 2014 12:01 am

Can't you just save/load to webstorage and use a global var to ensure the load function only runs once?

In terms of saving, if all you're doing is keeping track of levels cleared, it's a trivial matter to just update your save whenever the player beats a level. Assuming you are using an array, even with a few hundred levels, the overhead is trivial even on a weak device.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Tue Nov 25, 2014 9:54 am

I think your're right. Actually it's even simpler than an array - I'm just saving the number of the max unlocked level in a variable.

[Edit] Works like a charm. Thanks! I'm no beginner to C2 but I never needed WebStorage before. Now that I discovered how hassle-free it is I'm actually excited!:)
B
16
S
7
G
1
Posts: 161
Reputation: 3,131


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 15 guests