Shared Object Not saving the level Progress
Posted
by
user3536228
on Game Development
See other posts from Game Development
or by user3536228
Published on 2014-05-05T15:23:37Z
Indexed on
2014/06/05
15:41 UTC
Read the original article
Hit count: 224
I am making a flash game in which i have a variable levelState that describes the current level in which user has entered I am using SharedObject to save the progress but it does not do so first i declred a clas level variable
private var levelState:Number = 1;
private var mySaveData:SharedObject = SharedObject.getLocal("levelSave");
in the Main function i am checking if it is a first run of the game like below
if (mySaveData.data.levelsComplete == null)
{
mySaveData.data.levelsComplete = 1;
}
and in a function where the winning condition is checked so that levelState could be increased i am usin this sharedobject to hold the value of levelState
if (/*winniing condition*/)
levelState++;
mySaveData.data.levelsComplete = levelState;
mySaveData.flush();
setNewLevel(levelState);
}
but when i play the game clear a level and again run the game it does not start from that level it starts from beginning.
© Game Development or respective owner