I want to create a game that keeps track of your money. I want the value of the money to be the same throughout the life of the game, not just for one play... I've been told that webstorage is where I should go, but how do I set variables in webstorage? I also want to know how to acquire the data that has been storwed and display it. Kind of like a shop. Can someone upload a .capx with everything in webstorage, or educate me as to how I would accomplish this? Much obliged.
Here is a capx. You click the button to rack up a score and store it. Click it a few times, close the program, then reopen it and the score should take up where you left off before. This should work even in the C2 preview. Read the manual for more.
Thanks jimand but can I add local keys other than numbers, like variables?
With Webstorage, you save key / value pairs. The values can be numbers or text.
In my example the local storage key was "StoredScore" and the value was a number. You can do the same thing with text. You could have a key "Item" and a value of "lamp" or "table" or whatever.
Arrays if you are clever...
Sprites if you're REALLY clever (base64 strings or something I think)
sqiddster can you show me an example of web storage from your game airscape?
I use webstorage just to remember what level the player is up to. All you need is the action "set local value" and then the webstorage expression "webstorage.localvalue()".
—: Have a look at the "How do I FAQ" section "Webstorage", I guess you'll have the answer you're looking for.
Save variables/example of use
Remember a variable can be put about anywhere in an expression field, just don't use quotes.
Can I store images in Arrays - using key-value pairs? Should I use WebStorage?
Develop games in your browser. Powerful, performant & highly capable.
I don't see why you would need to store an image, since there is no way to create images at runtime anyway...
Thanks. I need help for a Hangman game. How do I connect typed text to the display?