How do I save multiple level scores in global variable ?

Get help using Construct 2

Post » Sat May 09, 2015 10:37 am

hi,

I have another queries about using global variable & local storage ?

In my game I have 20+ levels now I am using one global variable i.e. "score" .....

So as i have 20+ levels & they are all using diff event sheets so how can I get all score to use single global variable "Score" & use local storage to save it ....

So if anyone can help me use one global variable for all 20+ levels ....

Mike
Image
B
36
S
13
G
1
Posts: 99
Reputation: 3,051

Post » Sun May 10, 2015 7:19 am

You can use a dictionary instead, it's global and you'll have an easier time managing it, then you can save it as json and load it again.

If you insist on using a var, you can use "token", which are separators inside the string:

var score = "43412,43245,12354,12543";

using:

tokenat(score,0,",");

will send you back the first score in the string, 0 is a loopindex number for each token in the string, level1=0, level2=1, level3=2, etc.
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713

Post » Mon May 11, 2015 5:53 pm

So once used var & save my score as you say .... could you tell me as how to save it on local storage ..... as I am using this for the first time I need a little help ?

Thanks for quick response ......
Image
B
36
S
13
G
1
Posts: 99
Reputation: 3,051

Post » Mon May 11, 2015 5:55 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 20 guests