(Finished) Need help with Local Storage

Discussion and feedback on Construct 2

Post » Mon Oct 31, 2016 8:36 pm

Hey,

So I got these events:
Image

But when I close the game and reopen it, the variable does not change...
What am I doing wrong?
Last edited by TRMG on Tue Nov 01, 2016 8:18 pm, edited 1 time in total.
ImageImageImageImage
B
27
S
9
G
7
Posts: 229
Reputation: 5,493

Post » Mon Oct 31, 2016 8:58 pm

You have to have the following layout:

Code: Select all
Get item "HighScore" [action]
On item get "HighScore" [event]
   -> Set HighScore to LocalStorage.ItemValue [action]
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Mon Oct 31, 2016 9:34 pm

randomly wrote:You have to have the following layout:

Code: Select all
Get item "HighScore" [action]
On item get "HighScore" [event]
   -> Set HighScore to LocalStorage.ItemValue [action]

Great, thank you!
ImageImageImageImage
B
27
S
9
G
7
Posts: 229
Reputation: 5,493

Post » Mon Oct 31, 2016 10:48 pm

Heads up for anyone doing this:
It does not work if the variable name and the local storage key name are the same
ImageImageImageImage
B
27
S
9
G
7
Posts: 229
Reputation: 5,493

Post » Tue Nov 01, 2016 12:01 pm

Hey, please follow these steps, i hope helps you,

http://d.top4top.net/p_305a18v01.png
1. in start page of your game you need to do like this image, and you need also to make unique local variable for local storage only, and call it record, (Means every score that user receive will be recorded in record variable,
http://e.top4top.net/p_3055le1c2.png
2. this image here you make a record variable, as you see inside the image, the high score will set same number with the record, set high score to record to stay on the same level that you received, note; ( local storage and record variable never removed if you set item currently.you set this on level selection page.
http://f.top4top.net/p_30579jjx3.png
3. in the whole levels, you must make a sup event behind the score that the use will received to save it in the record, this will save your high score even when you close and open the game in the browser or mobile phone it is the same.
B
19
S
7
G
1
Posts: 62
Reputation: 1,954

Post » Tue Nov 01, 2016 8:17 pm

SaRaB wrote:Hey, please follow these steps, i hope helps you,

http://d.top4top.net/p_305a18v01.png
1. in start page of your game you need to do like this image, and you need also to make unique local variable for local storage only, and call it record, (Means every score that user receive will be recorded in record variable,
http://e.top4top.net/p_3055le1c2.png
2. this image here you make a record variable, as you see inside the image, the high score will set same number with the record, set high score to record to stay on the same level that you received, note; ( local storage and record variable never removed if you set item currently.you set this on level selection page.
http://f.top4top.net/p_30579jjx3.png
3. in the whole levels, you must make a sup event behind the score that the use will received to save it in the record, this will save your high score even when you close and open the game in the browser or mobile phone it is the same.

Thank you SaRaB, but randomly helped me already...
ImageImageImageImage
B
27
S
9
G
7
Posts: 229
Reputation: 5,493


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests