You save the scene to a binary .j3o
file, and similarly, you save display settings to an XML file. The next time your users run the game, you want to present them with their previously selected display settings.
Return to your
AppSettings.java
file.In your
main()
method, load previously saved settings, if they exist; configure a new settings objects if it doesn't exist:public static void main(String[] args) { AppSettings settings = new AppSettings(true); try { settings.load("com.foo.MyCoolGame"); } catch (BackingStoreException ex2) { Logger.getLogger(AppSettingsDemo.class.getName()).log(Level.WARNING,"failed to load settings, reverting to defaults", ex); settings.setTitle("My Cool Game"); // init defaults here… }
Then continue to save your settings:
AppSettingsDemo app = new AppSettingsDemo(); try { settings.save("com.foo.MyCoolGame"); } catch (BackingStoreException ex) { Logger.getLogger(AppSettingsDemo.class...