Introduction
Game saving is one of the most important feature in modern games as well as large games that takes many days to finish.
snippet
Preview Code in Design mode
saveGame("mySave", function(success:Bool):Void
{
});
code withou import com.stencyl.behavior.Script.*;
Scritpt.saveGame("mySave", function(success:Bool):Void
{
});
The 2 codes above shows that the default save name is mySave. The save name can be changed but must not contain space and other illegal characters. However the save name both load and save must be exact the same otherwise the save will not work and they are case-sensitive.
The use of code allows to change save name so that each game can have multiple save profile or save slot (1 save file per profile)
computational shortcut level 1
requires import flesh.net.SharedObject
and import com.stencyl.utils.Utils
var so:SharedObject = SharedObject.getLocal(fileName);
for(key in engine.gameAttributes.keys())
{
Utils.saveToSharedObject(so, key, Engine.engine.gameAttributes.get(key));
}
Utils.flushSharedObject(so, onComplete);
No comments:
Post a Comment