How to implement a game launch counter in LibGDX
- by Vishal Kumar
I'm writing a game using LibGDX in which I want to save the number of launches of a game in a text file.
So, In the create() of my starter class, I have the following code ..but it's not working
public class MainStarter extends Game {
private int count;
@Override
public void create() {
// Set up the application
AppSettings.setUp();
if(SettingsManager.isFirstLaunch()){
SettingsManager.createTextFileInLocalStorage("gamedata");
SettingsManager.writeLine("gamedata", "Launched:"+count ,FileType.LOCAL_FILE );
}
else{
SettingsManager.writeLine("gamedata", "Not First launch :"+count++ ,FileType.LOCAL_FILE );
}
//
// Load assets before setting the screen
// #####################################
Assets.loadAll();
// Set the tests screen
setScreen(new MainMenuScreen(this, "Main Menu"));
}
}
What is the proper way to do this?