i have one question now
local storage saves variables in devices or PC
but
Is save & load, save data on devices too??
Yes
actually i have made a levels game
and now i have no idea how to save
i should just use save & load or should use local variable
You have to decide when its worth saving. You are getting a bit confused about how to use it correctly it seems from your screenshot.
Here is an example of how to set it up, this is what the program looks like:
And this is the code:
The way the program works is that if you click the button "Check if key "Test" exists it will check if a key named "Test" is currently stored in the local storage. This is code (2) in the screenshot.
If a key named "Test" doesn't exists it will create a key called "Test" and set its value to "Test now have a value" also it will write in the list "Key missing", this is code (3) in the example and will look like this:
If you click the button "Check if key "Test" exists" once more. The key now exists, so its no longer missing. So it will now instead use code (4) and write to the list "Key Test exists" and it will now look like this:
Clicking the button "Load content of key "Test"" will get the value from the local storage, which I put to "Test now have a value". This is code (5). When the data have been loaded code (6) will be executed as well. And will look like this:
The reason for code (1) and to clear the storage on start of layout. This is simply for testing purposes as the key "Test" will still be in the storage even if you restart the application. So if you want to keep the value of "Test" in the storage, you have to remove code (1).
Using local storage for saving a few variables or part of you games progress is good. However as I mentioned it not very good if you want to save the complete state of your game. Because you will have to store a lot of variables.
So before you start creating a save/load system you need to decide where it make sense to save and where it doesn't. For instant in your example it seems like you want to save every time the player picks up a coin. But wouldn't it be better to just save between maps and just use the Save/Load function instead?