Username or E-mail
Password (Forgot?)
New? Sign Up
Join or Sign In
Forums Stencylpedia Stencyl TV Translations Go Pro - Plans & Pricing Download Stencyl


Switch to Book Layout

1: Getting Started

  • Getting Started
  • Crash Course
  • Crash Course 2
  • StencylForge

2: Building Logic

  • What is a Behavior?
  • Creating a Behavior
  • Attributes
  • Game Attributes
  • Attribute Types
  • Events
  • Our Behaviors

3: Actors

  • What are Actors?
  • Animations
  • Motion & Forces
  • Physics
  • Controls
  • Collisions & Groups
  • Killing vs. Recycling
  • Tweening
  • Effects
  • Chapter 3 Challenge

4: Scenes

  • Scene Basics
  • The Camera
  • Tilesets
  • Regions
  • Drawing Text & HUDs
  • Changing Scenes
  • Music, Sounds & Channels
  • Backgrounds
  • Customizing Actors
  • Chapter 4 Challenge

5: Game Mechanics

  • Saving
  • Pausing
  • 3rd Party Services
  • Web Requests

6: Advanced Topics

  • Get/Set Attributes
  • Custom Events
  • Blending Modes
  • Lists
  • Custom Blocks
  • Continuous Collisions

7: Testing & Tuning

  • Testing Games
  • Optimizing Performance 1
  • Optimizing Performance 2

8: The Last 10%

  • Flash Publishing
  • Standalone Apps
  • iOS App Store
  • Chrome Store
  • Making Money

M1: Mobile - Intro

  • Getting Started
  • Testing on your Device
  • Flash -> iOS Guide

M2: Mobile - Basics

  • Atlases
  • Drawing Text
  • Retina Display
  • Accelerometer
  • Joystick
  • Universal Games

M3: Mobile - Services

  • iAds
  • Game Center
  • In-App Purchases

M4: Mobile - Publishing

  • Debugging
  • Publishing to the App Store
  • Optimizing Performance
  • Promoting your Game

A: Troubleshooting

  • Showstoppers
  • General FAQ
  • iOS FAQ
  • The 90% Memory Warning
  • Recovering Broken Games
  • Can't Export to SWF
  • Reloading Documents
  • Generating Logs
  • Flash Security Settings
  • How to Report Bugs

B: How-To Guides

  • Importing Assets
  • Scene Designer
  • Code Mode
  • Font Editor
  • Pencyl (Image Editor)
  • Tile Editor (Shapes)
  • Game Cleaner

C: Reference

  • Glossary
  • Block Reference
  • Useful Shortcuts
  • Stencyl API

D: Resources

  • Stencyl TV
  • Abigayl's Guides
  • Giving Critiques
  • Creating Extensions
  • Translating Stencyl
  • Credits

3.0 Drafts (In Progress)

  • What's New in Stencyl 3.0?
  • Setup (Android)
  • Setup (Desktop)
  • Setup (iOS) - Concepts
  • Setup (iOS) - Mac
  • Setup (iOS) - Windows
  • Testing iOS on Windows
  • iOS Troubleshooter

  • Mobile App Scaling
  • Full Screen Mode
  • Simple Physics
  • Backgrounding an App

  • iOS App Store
  • Mac App Store
  • Windows Store
  • Google Play
  • HTML5

  • Android Ads
  • Android Purchases (WIP)
  • 4" Form Factor (iPhone 5)
  • Mobile Input
  • Mobile Features

  • Extending the Engine
  • iOS / Android Extensions
  • Developing the Official Extensions
  • Developing the Engine

  • iAds (Revised)
  • Game Center (Revised)
  • iOS Purchases (Revised)
  • Atlases (Revised)
  • Drawing Text (Revised)
  • Joystick (Revised)
  • Accelerometer (Revised)
  • Sounds (Revised, WIP)
  • Debugging (Revised, WIP)
  • iOS Performance (Revised)
Level: Beginner

Saving Games

Saving progress is a fundamental part of most games. This article explains how our saving system works.

 

Contents

  • How Saving Works
  • How To: Saving and Loading
  • Detecting Failure
  • Where is Data Saved?
  • Challenge: Checkpoints


How Saving Works

Saving in Stencyl uses a game’s Game Attributes to save data.

Note: Need a refresher on Game Attributes? Visit our article on Game Attributes.

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 completely overwrite your Game Attributes and replace them with the values of those in the save file.

Saving and Loading are instant - these operations will not hang your game. That said, Saving and Loading are blocking operations in the sense that nothing else will happen until those operations are complete.

 

How To: Saving and Loading

Saving and Loading involve just use these two blocks. (Game > Saving)

That's it!


Detecting Failure

Occasionally, a player will be unable to save, usually due to restrictive security settings.

If saving/loading fails, you can detect this and use the “save succeeded” and “load succeeded” blocks react appropriately, such as showing an error message.

To use them, just drag them out as pictured.

Note: 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.

 

Where is Data Saved?

Flash games use Local Shared Objects. That is to say, it's stored by the browser indefinitely until cleared out.

iOS games store save data directly on the file system using CoreData. This data is not deleted until the game itself is deleted (and settings/data are explicitly told to be removed).

 

Summary

  • Saving is based on Game Attributes.
  • Loading will overwrite all Game Attribtues.
  • Saving/Loading is an instant operation.


Challenge: Checkpoints

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 begin from the last checkpoint he reached.



Last Updated: 2012-04-03 by Jon

13200 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game, please ask a question on the forums. Thanks!
5 Comments
xandramas
my confusion is not the saving of the attributes its the loading and initial setting of the players stats before the first save. How do you tell the player he has a game attribute value of 5 when the player starts the game and it not change the value during the save? Put that initial game attribute value before the player loads the game, like on the start screen?
1 4 months, 3 weeks ago
Auni38
Nice, this works!
0 4 months, 4 weeks ago
DrunkenOrc
There's no specific place you have to put these code blocks. You can make the game save at any time you want; when something happens, when a button is clicked, and so on.

If you don't understand how to implement code blocks, you should read earlier sections of this wiki. Once you understand the basics of Stencyl, this section will make more sense.

1 10 months, 1 day ago
Hunnenkoenig
As always, there is exactly zero help in this.
You just again tell me, that my car has 4 wheels and 4 seats, but you don't tell me, how I can drive it...

0 10 months, 1 day ago
72master
this only shows me what block i need to use i dont know where to put it how to use it in design mode so this is pretty much a tease
1 10 months, 3 weeks ago



Commenting Guidelines

Sign In to Comment

Make Games

  • What is Stencyl?
  • Roadmap
  • Pricing

Play

  • Arcade
  • Showcase

Community

  • Forums
  • Chat
  • Translations

Help

  • Stencylpedia
  • Stencyl TV

About Us

  • Blog
  • Contact Us
  • Press
  • Privacy
Follow Stencyl on Twitter



© 2013 Stencyl, LLC.