by Jon (Updated on 2015-10-18)
Saving progress is a fundamental part of most games. Our saving system uses a game’s Game Attributes to save data. All you have to do is structure your game such that anything you want to save is stored in Game Attributes.
Similarly, loading a save file will overwrite the running game's Game Attributes and replace them with the values of those in the save file. For this reason, it's best to load a save file as early as possible.
Saving and Loading involve these two blocks. (found under Game > Saving)
The game attempts to save / load. This is quick (nearly instant), but the game will not progress until the save / load operation is complete or has failed.
When the save is complete (or has failed), the body (inside) of the block will run.
We talk more about how to handle failure next.
Sometimes, a player will be unable to save due to restrictive security settings or other reasons.
If saving/loading fails, you can detect this and use the save succeeded and load succeeded blocks to react appropriately, such as showing an error message.
To use them, just drag them out as pictured and use them as you see fit.
Warning: Don't use the save/load succeeded blocks outside the scope of the save/load wrapper, or you'll run into a compile-time error.
There's no hard rule for this, but for most games, doing it early on in the game's first scene makes sense. Remember again that loading will overwrite the game's game attributes.
Suppose that the player is playing your game for the first time. How do you know this? You could create a game attribute called "first time" that is initially set to true. When you save the game, it's set to false, so that when the game is loaded up again, that flag will now always be false.
It depends on the platform.
Flash games use Local Shared Objects. That is to say, it's stored by the browser indefinitely until cleared out.
Mobile games store save data directly on the device's file system but within the confines of the app's sandbox. This means that the data is "safe" and cannot be tampered with by any other apps.
This save data is not deleted until the game itself is deleted (and settings/data are explicitly told to be removed).
Note: At this time, it isn't possible to specify custom save locations or write out arbitrary data at runtime.
Many games use a checkpoint system, a system in which reaching a certain part of the level will guarantee that, if a player dies, the player can continue from that checkpoint, rather than starting from the beginning.
Create a simple checkpoint system for your game, such that even if the player exits out of the game, he’ll automatically begin from the last checkpoint he reached.