I have a level scene that i allow the user to select a level.
But to move on to the next level the user must complete the level before it.
Right now the first level which is automatically unlocked.
When it is completed i want unlock the second level. and when the second level is completed, unlock the third level.
i cant think of how i would go about doing this. i thought of sharedpreferences but dont know the logic i should use for this.
i could use some help on the logic behind this.
Any can help me out?
EDIT:
In my gameplay scene when is game is completed i call this to sharedpreference
editor.putString("level_completed"+level, "unlocked");
editor.commit();
Then i do..
String levelStatus = preference.getString("level_completed:"+level, "locked");
if(levelStatus.equals("unlocked")){
}else{
if(level == 0){
box.setUserData("unlocked");
}else{
box.setColor(1.0f,0.0f,0.0f);
box.setUserData("locked");
}
}
in the level selection scene to check if the level is unlocked.
This doesnt seem to be working to well. A level that should be unlocked isnt unlocked.