So how saving works is you're saving data. You can't save the state or the screen.
There are 2 tricks with saving and loading.
- know what you want to save/load
- know when to save/load. This one is the most important, because it can drastically change your results.
So, say you want to save 5 points when you press a save button.
You can do something like this:
Stopped touching --> Save to File
Then on the save behaviour properties, add a key (this is how you will reference what you saved). So enter something like Score.
In the next box you enter the score value it self that you want saved. So drag in the points from either a box container, or "get Label" behaviour into this field.
Now when the user pressing a "save" button it will save.
In a real world, you probably don't want to have a save button. Instead you would want to save when your character does something. Beats a high score, loses, wins etc.
Next you would need to load.
How you want to use that data depends on the load. The flow of loading data usually works like this:
- On scene start: Load behaviour
- Then output that loaded data into a label or some other useful object.
Often times with loading errors, users try making use of the data before it's actually loaded.
So in this example, we will just make a load button.
Like save, do a stopped touching --> Load from file
On the load behaviour properties select the Score key.
Then add something like set label, and connect it to the load. Then output the loaded value to the set label.
Here is an example project on saving/loading
Now for your other question on saving/loading the screen. This is more tricky. And depends heavily on your game. Something like an RPG game, saving/loading is a challenge. You would need to save many things. Characters position, inventory, health, skill etc. All of these would be individual keys/values in the save to file behaviour.
The when you start the game, load each one and then "set up" the scene with the data.