Webstorage Forum Home > Construct 2 General > Construct 2 general |
Post Reply
|
Page 12> |
| Author | |
Post Options
Quote Reply
Topic: WebstoragePosted: 08 May 2012 at 1:03am |
|
|
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.
|
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 1:48am |
|
|
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.
http://dl.dropbox.com/u/6109058/webstorage_test.capx |
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 1:54am |
|
|
Thanks @jimand but can I add local keys other than numbers, like variables?
|
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 2:17am |
|
|
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. http://www.scirra.com/manual/120/webstorage |
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 2:31am |
|
|
Numbers, text...
Arrays if you are clever... Sprites if you're REALLY clever (base64 strings or something I think) |
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 2:57am |
|
|
@sqiddster can you show me an example of web storage from your game airscape?
Edited by SearingSky - 08 May 2012 at 2:58am |
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 11:14am |
|
|
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()".
|
|
![]() |
|
Post Options
Quote Reply
Posted: 08 May 2012 at 11:49am |
|
|
@SearingSky: 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. |
|
![]() |
|
Post Options
Quote Reply
Posted: 14 May 2012 at 8:12pm |
|
|
Can I store images in Arrays - using key-value pairs? Should I use WebStorage?
|
|
![]() |
|
Post Options
Quote Reply
Posted: 14 May 2012 at 8:13pm |
|
|
I don't see why you would need to store an image, since there is no way to create images at runtime anyway...
Edited by sqiddster - 14 May 2012 at 8:13pm |
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |