How do I Save global variable highscore even exit the app

Get help using Construct 2

Post » Thu Jan 28, 2016 4:58 pm

Hi! I got a problem, I want to save the global variable highscore even exiting the app and I When I enter the game again show me the highscore I did before. I'm using localstorage to save the highscore. I using too Cocoon.io for the apk.

Thank you!
B
30
S
10
G
3
Posts: 25
Reputation: 4,228

Post » Thu Jan 28, 2016 5:13 pm

Kermad wrote:Hi! I got a problem, I want to save the global variable highscore even exiting the app and I When I enter the game again show me the highscore I did before. I'm using localstorage to save the highscore. I using too Cocoon.io for the apk.

Thank you!


Use this event:

This event is taking place in a single layout (example)

Add 1 Global Variable named "HighScore"
Note: In the event On item missing (We will create a LocalStorage key named "Highscore")

On start of layout..
---->Local Storage Check for item ("Highscore")

On Item found ("Highscore")
----->Set value Highscore to (LocalStorage.Itemvalue)

On Item missing ("Highscore")
------>Set LocalStorage Item ("Highscore") to 0

On end of layout
------>Set LocalStorage item ("Highscore") to Highscore
Image



The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
54
S
17
G
90
Posts: 1,111
Reputation: 59,120

Post » Thu Jan 28, 2016 8:07 pm

That helps! Thanks, but now I have this problem, when I restart the layout the highscore show 2 values. :(

https://dl.dropboxusercontent.com/u/797 ... index.html

Image
B
30
S
10
G
3
Posts: 25
Reputation: 4,228

Post » Thu Jan 28, 2016 10:52 pm

Solved
B
30
S
10
G
3
Posts: 25
Reputation: 4,228


Return to How do I....?

Who is online

Users browsing this forum: ankas, mekonbekon, RobertMKD, Yahoo [Bot] and 15 guests