Save and load current level in this capx?

Get help using Construct 2

Post » Sat Jun 14, 2014 3:28 pm

Hi everyone,

I have been looking at this capx:
https://dl.dropbox.com/u/8367729/constr ... lect6.capx

Which works fine, except it wont save and load the current level (text) & currentLevel global variable..
It remembers the open level images, but the current level text ramains as "current level=1" when you refresh the browser.

Does anyone know how to keep the current level?
I really, really need your help guys!

Here is an example:
2222.png
You do not have the required permissions to view the files attached to this post.
B
37
S
9
G
8
Posts: 541
Reputation: 8,554

Post » Sat Jun 14, 2014 4:33 pm

You just need to save the variable to webstorage when it changes and then load it again on start of layout.

But the currentLevel variable in that capx is just used to track the level you're currently playing so that it knows which values to update when you complete the level. It gets set when you click on a level button to start a level. There's no need to save/load it really.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Jun 14, 2014 5:18 pm

Hi ramones, thanks so much for the answer!
Thats really nice of you :0)

I tried that as the first thing, but i get an "key does not exist"
Is there a chance that you could provide an example? maybe just update the capx in this thread and post it?
Im really puzzled about this. It would be extremely helpful!

i was sitting and waiting for someone to repond, so thanks again!
B
37
S
9
G
8
Posts: 541
Reputation: 8,554

Post » Sat Jun 14, 2014 8:55 pm

Load from WebStorage (on start of layout):
loadFromWebstorage.PNG

Save to WebStorage (whenever currentLevel is changed):
saveToWebstorage.PNG


Why do you want to store that variable?
You do not have the required permissions to view the files attached to this post.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sat Jun 14, 2014 9:47 pm

Ramones, your awesome! Thanks man..
Could it be that i was missing the "int"?

I need to store the value because im making an interactive level select map (like candy crush on facebook)
Where the player moves along the map, from the last played lvl.. Its a bit complicated, but thanks to you it now works! so thanks again!
B
37
S
9
G
8
Posts: 541
Reputation: 8,554

Post » Tue Jul 14, 2015 6:22 pm

@xanxion Is your level select map displays your facebook friends progress? (Like Candy Crush does with your friends pictures). I did not find a way of doing that will all the facebook plugins I saw on scirra.
B
81
S
21
G
23
Posts: 515
Reputation: 18,702


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 40 guests