Libgdx: Different profiles of Preferences -


i've searched around , haven't found related i'm trying achieve.

to explain simple possible. app stores various number of values, acting settings user basically. want user have ability switch between different preference files. different profiles. on click of button instances of preferences through app start reading different file different values, example:

main.preferences = gdx.app.getpreferences("prefs_2"); 

where first profile "prefs_1" instead loaded default when app starts. don't know if changing preference file shown above work @ all. hope gives idea of how i'm thinking.

and when clicking button change preference file, app read file's values through out classes in app until restarted go default file:

public class main extends game { public spritebatch batch; public shaperenderer renderer; private assets assets;  //local preferences public preferences preferences;  public main(utilsinterface utils){     this.utils = utils; } @override public void create () {     batch = new spritebatch();     renderer = new shaperenderer();     assets = new assets();     preferences = gdx.app.getpreferences("prefs_1");      setscreen(new splashscreen(this)); } @override public void render () {     super.render();  } @override public void resize(int width, int height) {     super.resize(width, height); }  @override public void dispose() {     super.dispose();     assets.dispose();     batch.dispose();     renderer.dispose(); } @override public void pause() {     // todo auto-generated method stub     super.pause();     // logs 'app deactivate' app event.     // appeventslogger.deactivateapp(this); } @override public void resume() {     // todo auto-generated method stub     super.resume();     //assets.manager.finishloading();     // logs 'install' , 'app activate' app events. } 

}

note* use same instance of preferences main class throughout whole app.

yes, work.

if use different settings file, use settings of file. make sure have default values settings if new file created (when open file not exist, write , flush it) can still use without having settings written it.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -