Introduction
Without ability to load game, saving game would be useless. In fact they cannot work without each other. In stencyl, savinggame is loading game is very similar. just replace save with load until you reverse-engineer how they woirk.
snippet
preview code in Design Mode
loadGame("mySave", function(success:Bool):Void
{
});
code withour import com.stencyl.behavior.Script;
Script.loadGame("mySave", function(success:Bool):Void
{
});
The 2 codes abve shoes that the default save name is mySave. save name on both and load mist be the same before loading and saving feature can work
computational shortcut level 1
requires import flesh.net.SharedObject
and import com.stencyl.utils.Utils
var so:SharedObject = SharedObject.getLocal(fileName);
for(key in Reflect.fields(so.data))
{Engine.engine.gameAttributes.set(key, Utils.loadFromSharedObject(so, key));}
if (onComplete != null) onComplete(true);
No comments:
Post a Comment