How do I Show score using web storage

Get help using Construct 2

Post » Mon Mar 02, 2015 4:59 pm

Hi, i tried to figure it out myself , but it never worked :-/. So what i have is global variable Called Timer. It measure how long it takes to finish the level. Every second i am adding 1 to the timer. When you finish the level it opens another layout with score statistic , i need to show the final timer value. But i have no idea how to do this. Any ideas? thank you
B
11
S
3
G
1
Posts: 411
Reputation: 1,766

Post » Tue Mar 03, 2015 2:03 pm

If you want to use WebStorage you need to save your data to it and then - read it.
To save data to WebStorage use Set local value action. Use any key and store you Timer value (example, key: "finish_time" value: Timer).
Any time you want read it with WebStorage.LocalValue(key) expression.
Our example: Text.SetText -> WebStorage.LocalValue("finish_time")
You'll take your last Timer value.

It will be still there even if you close your browser and open it again.
B
8
Posts: 72
Reputation: 456

Post » Tue Mar 03, 2015 2:21 pm

Yep! Nick is right
Anyway you should read this:
https://www.scirra.com/manual/120/webstorage
B
69
S
19
G
9
Posts: 639
Reputation: 8,989

Post » Tue Mar 03, 2015 2:26 pm

hi and thank you, but always, when the level finish the value is reset to 0, so it showes me 0 as final time.
B
11
S
3
G
1
Posts: 411
Reputation: 1,766

Post » Tue Mar 03, 2015 2:34 pm

you need to save it to WebStorage BEFORE you close your layout or it will cause your progress to lose
B
8
Posts: 72
Reputation: 456

Post » Tue Mar 03, 2015 2:36 pm

ok i will try something , thank you :-)
B
11
S
3
G
1
Posts: 411
Reputation: 1,766


Return to How do I....?

Who is online

Users browsing this forum: dcadjust, Husui, mantap100 and 24 guests