How to implement a game launch counter in LibGDX

Posted by Vishal Kumar on Game Development See other posts from Game Development or by Vishal Kumar
Published on 2013-06-21T01:37:43Z Indexed on 2014/08/22 10:28 UTC
Read the original article Hit count: 273

Filed under:
|

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?

© Game Development or respective owner

Related posts about android

Related posts about libgdx