New in this release: full state save and load, persistent layouts and continuous preview!
Previously WebStorage allowed you to save and load simple values, such as the current level or checkpoint reached. However it was difficult to use WebStorage to save an entire game in the middle of the action - so you can save at any time, and resume with the game exactly where you left off. This is what the full-state save and load actions in the System object now allow. The other features are explained further below.
Full-state saving and loading
The new Save and Load system actions can be used to save the complete state of the game easily. Everything from object positions, sizes, angles, opacities, each of their behaviors, all their instance variables, effect parameters, global variables, and so on - are all saved in to a big block of data. You can save to different "slots" - e.g. "save1", "save2", "save3" and "quicksave" - to allow keeping multiple separate savegames on the same computer.
The full-state save-games can be quite large, since they store every last detail of the game state. They can easily be over a hundred kilobytes. WebStorage is limited to 5mb on most browsers. This is probably enough for even a large game to store several savegames. However for peace of mind there's a new IndexedDB storage system for save games. IndexedDB is a new database-like HTML5 feature supported by most modern browsers (check if your browser supports it with ScirraMark, and note node-webkit does support IndexedDB). It has much larger storage limits, usually at least 50mb or so. When supported, savegames get stored in IndexedDB. This means the savegame data doesn't contribute to the 5mb WebStorage quota, allowing you to safely use WebStorage for other things. If IndexedDB is not supported then it still uses WebStorage, which should be fine for all but the very largest games using many save slots, and IndexedDB is getting more support from browsers over time anyway.
You can even access the JSON data of the save state directly, and load from JSON strings. This means if you have a server-side, you can AJAX post save games to your server. Then your players could share their savegames across browsers and devices!
Full-state save and load is a very complicated feature. It touches almost every aspect of the runtime, and support has to be written for each individual plugin and behavior. This means existing third party plugins and behaviors won't support it until the developers update them. Also for some plugins and behaviors the state is quite complex. A few examples are: the Audio plugin restores the currently playing audio at the correct playback time, with any positioning and effects; the Pathfinding behavior tries to restore pathfinding operations that were still calculating when the game was saved; and the Physics behavior does its best to restore the forces and velocities at the moment of save. This means bugs may be relatively likely and affect only certain plugins and behaviors. Please be vigilant and report bugs with loading savegames using the full form in the Bugs forum if you encounter any issues.
There are also several things that Construct 2 makes no effort to save. These are generally network related things that are impossible, difficult or unreliable to try to save and load. For example, in-progress AJAX requests are not saved or loaded; WebSocket connections are not reconnected; the XML object won't save its currently loaded document; the User Media object won't try to re-start a video feed if it was live when saving; the Facebook object won't log you in again if you were logged in when saving; and of course the WebStorage state is not saved or loaded. I don't anticipate this to be a problem, but it's worth bearing in mind.
Savegames should be relatively robust to changes in your project. You should be able to do things like rename objects, add and reorder instance variables, adjust behaviors and so on - all without stopping old savegames from still loading correctly. However note if you make major changes, such as deleting layers, entire object types, or even removing entire layouts, Construct 2 won't be able to associate a lot of the data with anything, and old savegames may load strangely. Also note if you add something new, existing savegames won't have any data for it, so the object will act as if it has the 'No Save' behavior when loading (see below). So if you have already published a game and want to make sure savegames keep working as intended, be careful what you add and remove.
New related behaviors
There are also two new behaviors which are useful and are related to the full-state saving and loading.
First, the new No Save behavior simply omits the object from save game data. This also means when loading, the object isn't touched and all the old objects from before the load are still there with the same properties. This can be useful if you have trouble with savegames being too large or slow to load. You can easily omit static scenery objects which aren't necessary to save, for example. You also might want to make savegames smaller to post to a server quicker, or you simply want to keep some data after loading (e.g. only allowing the player to load a limited number of times). A good example of using the behavior is in the Rain Demo: the majority of the objects are raindrops and splashes, but they run automatically and don't really need saving. By adding the No Save behavior the savegame size reduces from about 100kb to 20kb (5 times smaller!) and the visual difference is virtually imperceptible.
Second, the new Persist behavior allows you to make persistent layouts. Normally if you leave a layout then return to it, all its objects have reverted to the initial state as you designed in the editor. Sometimes this is annoying if you want, say, the player to return to a previous level but with all the enemies they killed and powerups they collected still gone. Now you can simply add the Persist behavior to objects you'd like to remember - in this case, the enemies and powerups. Then on returning to the layout, all those objects are exactly as you left them. This is great for non-linear games where you want the player to come through a previous section, but without having to re-do everything they did before.
This is the most experimental of the new features, but also potentially very powerful. While testing save/load, it became obvious the save/preview/load cycle was useful. It allowed you to make changes to a level and preview them without resetting the level back to the start. So this has been automated with continuous preview: simply hold shift and click Preview (or Shift+F5) and the game will execute a save, reload project, and load cycle. The URL will also end with "?continuous" to indicate a continuous preview. This means you can alter events as you play the game, and also makes it possible to design levels as you play them. Note your scenery objects must have the 'No save' behavior for design-as-you-play to work, otherwise loading will faithfully load the previous state of the scenery. However it allows for intriguing possibilities; imagine play-testing a level for 5 minutes, finding some misplaced scenery, correcting it in the editor, then continuing from where you left off with the corrected level. No need to reset back to the beginning and play through for another 5 minutes!
The new Pause on unfocus project property is designed to be useful with continuous preview. If enabled, when you switch focus back to Construct 2 the game pauses. This prevents your player being killed, running out of time, or whatever, while you're back in the editor making changes. Then you can continuously preview from the point it got paused.
As mentioned, this is somewhat experimental; we're still working out the best way to fit it conveniently in to the workflow, so suggestions are welcome. It's also currently difficult to use for objects which are saved, like the enemies in levels. If saved, continuous preview will faithfully load them as they were saved, ignoring any changes you made in the layout view. We're thinking about ways we can improve this so you can still continuously preview changes to saved objects.
There's a lot new this build! Have fun trying it out and don't forget to report any issues you find. Hopefully we will have a stable release coming up soon, but since there were a lot of changes in this release we may leave it a while to ensure these features are reliable. Happy testing!