Okay so, I'm making a simple piggy bank application. There's plus and minus button. I made a global variable to store my savings and the plus button will add $1 to my savings but every time I quit the game/app(what ever you want to call it.) its resetting the variable to 0. Which the global variable initial value. Can I just declared the variable and not adding any initial value?
You have to keep the values of the variable in local storage if you want to remember its state after you close/exit the game, otherwise it will always reset to the initial value.
How to that may I ask..... I'm so sorry. Really, really sorry...
Develop games in your browser. Powerful, performant & highly capable.
See here the manual for local storage
https://www.scirra.com/manual/188/local-storage
See this post which had the same question which I helped solving
viewtopic.php?f=147&t=192946&p=1130941#p1130941
Also here is a screen for saving high score in an array which I used in my game
https://postimg.org/image/enyi4lp9x
I hope this will clear things, it will take you a bit to get used to using local storage, after that its easy.