Example usage for com.badlogic.gdx Preferences putFloat

List of usage examples for com.badlogic.gdx Preferences putFloat

Introduction

In this page you can find the example usage for com.badlogic.gdx Preferences putFloat.

Prototype

public Preferences putFloat(String key, float val);

Source Link

Usage

From source file:com.digitale.screens.InGameOptions.java

License:Open Source License

public InGameOptions(Stage stage) {
    originalsfxVolume = Stardust3d.sfxVolume;
    originalMusicVolume = Stardust3d.musicVolume;
    originalaccellXsensitivity = Stardust3d.accelXsensitivity;
    originalaccellYsensitivity = Stardust3d.accelYsensitivity;
    originalDeadzoneX = Stardust3d.deadzoneX;
    originalDeadzoneY = Stardust3d.deadzoneY;
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));

    Gdx.input.setInputProcessor(stage);//from   ww w.  j  a v  a  2 s . c om

    // Group.debug = true;

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonClose");
    final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel");
    ;
    final CheckBox checkBoxSFX = new CheckBox("Sound Effects", skin.getStyle(CheckBoxStyle.class), "checkbox");
    final CheckBox checkBoxFontsize = new CheckBox("Use Small Font", skin.getStyle(CheckBoxStyle.class),
            "checkboxfont");

    final Slider slidersfx = new Slider(0, 2, .1f, skin.getStyle(SliderStyle.class), "slidersfx");

    final Slider sliderdzy = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdzy");
    final Slider sliderdzx = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdzx");
    //sensitivty
    final Slider slidersy = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdsy");
    final Slider slidersx = new Slider(.1f, 2, .1f, skin.getStyle(SliderStyle.class), "sliderdsx");
    //stardust
    final Slider sliderdust = new Slider(20, 500, 10f, skin.getStyle(SliderStyle.class), "sliderdust");

    final Slider slidermusic = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersmusic");
    final Slider slidergfxquality = new Slider(0, 10, 1, skin.getStyle(SliderStyle.class), "slidergfx");

    slidersfx.setValue(Stardust3d.sfxVolume);
    slidermusic.setValue(Stardust3d.musicVolume);
    sliderdzx.setValue(Stardust3d.deadzoneX);
    sliderdzy.setValue(Stardust3d.deadzoneY);
    sliderdust.setValue(Stardust3d.dustsize);
    slidersx.setValue(Stardust3d.accelXsensitivity);
    slidersy.setValue(Stardust3d.accelYsensitivity);
    final Label lablesfx = new Label("Sound effect volume", skin.getStyle(LabelStyle.class), "lablesfx");
    final Label lablemusic = new Label("Music volume", skin.getStyle(LabelStyle.class), "lablemusic");
    final Label lablegfx = new Label("Graphics quality", skin.getStyle(LabelStyle.class), "lablegfx");

    final Label lablesliderdzx = new Label("Horizontal Deadzone", skin.getStyle(LabelStyle.class),
            "lablesliderdzx");
    final Label lablesliderdzy = new Label("Vertical Deadzone", skin.getStyle(LabelStyle.class),
            "lablesliderdzy");
    final Label lableslidersx = new Label("Horizontal Sensitivity", skin.getStyle(LabelStyle.class),
            "lableslidersx");
    final Label lableslidersy = new Label("Vertical Sensitivity", skin.getStyle(LabelStyle.class),
            "lableslidersy");
    final Label lablesliderdust = new Label("Spacedust Density", skin.getStyle(LabelStyle.class),
            "lablesliderdust");
    final Preferences prefs = Gdx.app.getPreferences("stardustpreferences");
    final Label lablestilt = new Label("Android Tilt Settings", skin.getStyle(LabelStyle.class), "labletilt");

    Window window = new Window("Options Screen", skin.getStyle(WindowStyle.class), "optionsWindow");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.defaults().pad(2);
    window.setFillParent(true);
    window.setMovable(false);
    // build table
    window.row().fill().expandX().maxHeight(28);
    window.add();
    window.add();
    window.add(buttonCancel).colspan(1);
    window.add(buttonClose).colspan(1);
    // audio slider lables
    window.row().fill().expandX().maxHeight(28);
    window.add(checkBoxFontsize);
    window.add();
    window.add(lablestilt).maxWidth(350).fillX().colspan(2);

    window.row().fill().expandX().maxHeight(28);
    //top row 
    window.add(lablesfx).maxWidth(350).fillX().colspan(2);
    window.add(lablesliderdzx).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(slidersfx).fillX().colspan(2);
    window.add(sliderdzx).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add(lablemusic).maxWidth(350).fillX().colspan(2);
    window.add(lablesliderdzy).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(slidermusic).fillX().colspan(2);
    window.add(sliderdzy).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add(lablesliderdust).maxWidth(350).fillX().colspan(2);
    window.add(lableslidersx).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add(sliderdust).fillX().colspan(2);
    window.add(slidersx).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);

    window.add().minWidth(100).maxWidth(350).fillX().colspan(2);
    window.add(lableslidersy).maxWidth(350).fillX().colspan(2);
    window.row().fill().expandX().maxHeight(28);
    window.add().fillX().colspan(2);
    window.add(slidersy).fillX().colspan(2);
    window.row();
    // audio sliders

    window.pack();
    stage.addActor(window);

    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            prefs.putFloat("musicvolume", Stardust3d.musicVolume);
            prefs.putFloat("sfxvolume", Stardust3d.sfxVolume);

            prefs.putFloat("dzx", Stardust3d.deadzoneX);
            prefs.putFloat("dzy", Stardust3d.deadzoneY);
            prefs.putFloat("sx", Stardust3d.accelXsensitivity);
            prefs.putFloat("sy", Stardust3d.accelYsensitivity);

            prefs.putFloat("dustsize", Stardust3d.dustsize);
            Simulation.populateDust();
            prefs.flush();
            Stardust3d.stationScreen = 107;
        }
    });

    checkBoxFontsize.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("smallfont");
            Stardust3d.tinyfont = checkBoxFontsize.isChecked();
            // if user wants to change fontsize
            prefs.putBoolean("fontsize", Stardust3d.tinyfont);
            prefs.flush();
        }
    });

    buttonCancel.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            resetSettings();
            Stardust3d.stationScreen = 107;
        }
    });

    slidersfx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.sfxVolume = value;
            SoundManager.setSFXVolume();
            SoundManager.playconfirm();
        }
    });

    slidermusic.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.musicVolume = value;

            SoundManager.setMusicVolume();

        }
    });

    sliderdzx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.deadzoneX = value;
        }
    });
    sliderdzy.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.deadzoneY = value;
        }
    });

    slidersx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.accelXsensitivity = value;
        }
    });

    slidersy.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.accelYsensitivity = value;
        }
    });
    sliderdust.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.dustsize = value;
            SoundManager.setMusicVolume();
        }
    });
}

From source file:com.digitale.screens.Options.java

License:Open Source License

public Options() {
    originalsfxVolume = Stardust3d.sfxVolume;
    originalMusicVolume = Stardust3d.musicVolume;

    batch = new SpriteBatch();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    background = new Texture(Gdx.files.internal("data/bgpland.jpg"));

    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    Gdx.input.setInputProcessor(stage);// w w  w .j a  va2s .co  m

    // Group.debug = true;

    final Button buttonClose = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonClose");
    final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel");
    ;
    final CheckBox checkBoxSFX = new CheckBox("Sound Effects", skin.getStyle(CheckBoxStyle.class), "checkbox");
    final CheckBox checkBoxFontsize = new CheckBox("Use Small Font", skin.getStyle(CheckBoxStyle.class),
            "checkboxfont");
    final Slider slidersfx = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersfx");
    final Slider slidermusic = new Slider(0, 1, .01f, skin.getStyle(SliderStyle.class), "slidersmusic");
    final Slider slidergfxquality = new Slider(0, 10, 1, skin.getStyle(SliderStyle.class), "slidergfx");
    slidersfx.setValue(Stardust3d.sfxVolume);
    slidermusic.setValue(Stardust3d.musicVolume);
    final Label lablesfx = new Label("Sound effect volume", skin.getStyle(LabelStyle.class), "lablesfx");
    final Label lablemusic = new Label("Music volume", skin.getStyle(LabelStyle.class), "lablemusic");
    final Label lablegfx = new Label("Graphics quality", skin.getStyle(LabelStyle.class), "lablegfx");

    final Preferences prefs = Gdx.app.getPreferences("stardustpreferences");

    Window window = new Window("Options Screen", skin.getStyle(WindowStyle.class), "window");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.defaults().pad(5);
    window.setFillParent(true);
    window.setMovable(false);
    //build table
    window.row().expandX().fill();
    window.add();
    window.add();
    window.add(buttonCancel).colspan(1);
    window.add(buttonClose).colspan(1);
    //audio slider lables
    window.row();
    window.add(checkBoxFontsize);
    window.row();
    window.row();
    window.row();
    window.row();
    window.add(lablesfx).minWidth(100).colspan(2);
    window.add(lablemusic).minWidth(100).colspan(2);
    // audio sliders
    window.row().expand();
    window.add(slidersfx).minWidth(100).maxWidth(350).fillX().colspan(2);
    window.add(slidermusic).minWidth(100).maxWidth(350).fillX().colspan(2);

    window.row();

    window.pack();
    stage.addActor(window);

    buttonClose.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            prefs.putFloat("musicvolume", Stardust3d.musicVolume);
            prefs.putFloat("sfxvolume", Stardust3d.sfxVolume);
            prefs.flush();
            if (Stardust3d.mloginOK) {
                Stardust3d.gameMode = 4;

                doneflag = true;
            } else {
                Stardust3d.gameMode = 2;
                doneflag = true;
            }
        }
    });
    checkBoxFontsize.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("smallfont");
            Stardust3d.tinyfont = checkBoxFontsize.isChecked();
            //if user wants to change fontsize
            prefs.putBoolean("fontsize", Stardust3d.tinyfont);
            prefs.flush();
        }
    });
    buttonCancel.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            System.out.println("Options Close");
            SoundManager.playuiclick();
            if (Stardust3d.mloginOK) {
                Stardust3d.gameMode = 4;
                resetSettings();
                doneflag = true;
            } else {
                Stardust3d.gameMode = 2;
                doneflag = true;
            }
        }
    });
    slidersfx.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.sfxVolume = value;
            Gdx.app.log("Options", "sfxslider: " + value);
            SoundManager.setSFXVolume();
            SoundManager.playconfirm();
        }
    });
    slidermusic.setValueChangedListener(new ValueChangedListener() {
        public void changed(Slider slider, float value) {
            if (value == 0)
                value = 0.001f;
            Stardust3d.musicVolume = value;
            Gdx.app.log("Options", "musicslider: " + value);
            SoundManager.setMusicVolume();

        }
    });
}

From source file:com.kasetagen.game.bubblerunner.screen.BubbleRunnerMenu.java

License:Creative Commons License

private void assembleOptionsGroup(TextureAtlas atlas) {

    /*/*w  w  w  .j  a v a2  s  . c  om*/
     * Gather values
     */
    float sfxVolValue = gameProcessor.getStoredFloat(GameOptions.SFX_MUSIC_VOLUME_PREF_KEY);
    sfxVolValue = sfxVolValue < 0f ? 0f : sfxVolValue;
    float bgVolValue = gameProcessor.getStoredFloat(GameOptions.BG_MUSIC_VOLUME_PREF_KEY);
    bgVolValue = bgVolValue < 0f ? 0f : bgVolValue;

    charValue = gameProcessor.getStoredString(GameOptions.CHARACTER_SELECT_KEY);
    if (charValue == null || "".equals(charValue.trim())) {
        charValue = AnimationUtil.CHARACTER_2;
    }

    /*
     * Gather Reference Interatctions
     */
    Skin skin = gameProcessor.getAssetManager().get(AssetsUtil.DEFAULT_SKIN, AssetsUtil.SKIN);
    sfx = gameProcessor.getAssetManager().get(AssetsUtil.SND_SHIELD_ON, AssetsUtil.SOUND);

    /*
     * Add Scaffolding
     */
    GenericActor runnerScaffold = new GenericActor(0f, 0f, optionsGroup.getWidth(), optionsGroup.getHeight(),
            atlas.findRegion(AtlasUtil.ANI_OPTIONS_RUNNERSCAFFOLD), Color.WHITE);
    optionsGroup.addActor(runnerScaffold);

    GenericActor volumeScaffold = new GenericActor(0f, 0f, optionsGroup.getWidth(), optionsGroup.getHeight(),
            atlas.findRegion(AtlasUtil.ANI_OPTIONS_VOLUMESCAFFOLD), Color.WHITE);
    optionsGroup.addActor(volumeScaffold);

    Animation techAAni = new Animation(1f / 2f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_TECH_A));
    AnimatedActor techA = new AnimatedActor(TECHA_X, TECHA_Y, TECHA_W, TECHA_H, techAAni, 0f);
    optionsGroup.addActor(techA);
    Animation techBAni = new Animation(1f / 2f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_TECH_B));
    AnimatedActor techB = new AnimatedActor(TECHB_X, TECHB_Y, TECHB_W, TECHB_H, techBAni, 0f);
    optionsGroup.addActor(techB);

    /*
     * Add Player Buttons
     */
    Animation charAni = new Animation(1f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_CHARSELECT));
    charIndicator = new AnimatedActor(CHAR_SEL_X, CHAR_SEL_Y, CHAR_SEL_W, CHAR_SEL_H, charAni, 0f);
    charIndicator.setTargetKeyFrame(1);
    optionsGroup.addActor(charIndicator);

    Animation edynDefCircleAni = new Animation(0.5f / 10f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDYN_SELECT),
            Animation.PlayMode.REVERSED);
    Animation edynCircleAni = new Animation(0.5f / 10f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDYN_SELECT));
    edynCircle = new AnimatedActor(EDYN_CIRCLE_X, EDYN_CIRCLE_Y, EDYN_CIRCLE_W, EDYN_CIRCLE_H, edynDefCircleAni,
            0f);
    edynCircle.addStateAnimation("SELECTED", edynCircleAni);
    edynCircle.setIsLooping(false);
    optionsGroup.addActor(edynCircle);
    Array<TextureAtlas.AtlasRegion> edynImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDYN_EYES);
    TextureRegionDrawable edynUp = new TextureRegionDrawable(edynImgs.get(0));
    TextureRegionDrawable edynDown = new TextureRegionDrawable(edynImgs.get(1));
    edynSelect = new ImageButton(edynUp, edynDown, edynDown);

    edynSelect.setSize(CHAR_CIRCLE_SIZE, CHAR_CIRCLE_SIZE);
    edynSelect.setPosition(EDYN_SELECT_X, CHAR_CIRCLE_Y);
    edynSelect.addListener(listener);
    edynSelect.setChecked(AnimationUtil.CHARACTER_2.equals(charValue));
    optionsGroup.addActor(edynSelect);

    Animation eddyDefCircleAni = new Animation(0.5f / 10f,
            atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDISON_SELECT), Animation.PlayMode.REVERSED);
    Animation eddyCircleAni = new Animation(0.5f / 10f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDISON_SELECT));
    eddyCircle = new AnimatedActor(EDISON_CIRCLE_X, EDISON_CIRCLE_Y, EDISON_CIRCLE_W, EDISON_CIRCLE_H,
            eddyDefCircleAni, 0f);
    eddyCircle.addStateAnimation("SELECTED", eddyCircleAni);
    eddyCircle.setIsLooping(false);
    optionsGroup.addActor(eddyCircle);

    Array<TextureAtlas.AtlasRegion> edisonImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDISON_EYES);
    TextureRegionDrawable edisonUp = new TextureRegionDrawable(edisonImgs.get(0));
    TextureRegionDrawable edisonDown = new TextureRegionDrawable(edisonImgs.get(1));
    edisonSelect = new ImageButton(edisonUp, edisonDown, edisonDown);
    edisonSelect.setSize(CHAR_CIRCLE_SIZE, CHAR_CIRCLE_SIZE);
    edisonSelect.setPosition(EDISON_SELECT_X, CHAR_CIRCLE_Y);
    edisonSelect.addListener(listener);
    edisonSelect.setChecked(AnimationUtil.CHARACTER_1.equals(charValue));
    optionsGroup.addActor(edisonSelect);

    charDataSaver = new IDataSaver() {
        @Override
        public void updatePreferences(Preferences prefs) {
            prefs.putString(GameOptions.CHARACTER_SELECT_KEY, charValue);
        }
    };

    /*
     * Add Main Menu Button
     */
    Array<TextureAtlas.AtlasRegion> mmImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_MAINMENU);
    TextureRegionDrawable mmDown = new TextureRegionDrawable(mmImgs.get(1));
    mainMenuButton = new ImageButton(new TextureRegionDrawable(mmImgs.get(0)), mmDown, mmDown);
    mainMenuButton.setSize(MM_W, MM_H);
    mainMenuButton.setPosition(MM_X, MM_Y);
    mainMenuButton.addListener(listener);
    optionsGroup.addActor(mainMenuButton);

    /*
     * Add Sliders
     */
    Animation bgAni = new Animation(1f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_MUSIC));
    bgIndicator = new AnimatedActor(MUSIC_X, MUSIC_Y, MUSIC_W, MUSIC_H, bgAni, 0f);
    bgIndicator.setTargetKeyFrame(0);
    optionsGroup.addActor(bgIndicator);

    bgVolumeSet = new Slider(0f, 1f, 0.1f, false, skin);
    bgVolumeSet.setValue(bgVolValue);
    bgVolumeSet.setPosition(319f, 190f);
    bgVolumeSet.setSize(500f, 20f);
    optionsGroup.addActor(bgVolumeSet);
    bgDataSaver = new IDataSaver() {
        @Override
        public void updatePreferences(Preferences prefs) {
            prefs.putFloat(GameOptions.BG_MUSIC_VOLUME_PREF_KEY, bgVolumeSet.getValue());
        }
    };

    bgVolumeSet.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            gameProcessor.saveGameData(bgDataSaver);
            gameProcessor.setBGMusicVolume(bgVolumeSet.getValue());
        }
    });

    Animation sfxAni = new Animation(1f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_SFX));
    sfxIndicator = new AnimatedActor(SFX_X, SFX_Y, SFX_W, SFX_H, sfxAni, 0f);
    sfxIndicator.setTargetKeyFrame(0);
    optionsGroup.addActor(sfxIndicator);

    sfxVolumeSet = new Slider(0f, 1f, 0.1f, false, skin);
    sfxVolumeSet.setValue(sfxVolValue);
    sfxVolumeSet.setPosition(208f, 68f);
    sfxVolumeSet.setSize(500f, 20f);
    optionsGroup.addActor(sfxVolumeSet);
    sfxDataSaver = new IDataSaver() {
        @Override
        public void updatePreferences(Preferences prefs) {
            prefs.putFloat(GameOptions.SFX_MUSIC_VOLUME_PREF_KEY, sfxVolumeSet.getValue());
        }
    };

    sfxVolumeSet.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            gameProcessor.saveGameData(sfxDataSaver);
            sfx.play(sfxVolumeSet.getValue());
        }
    });

    selectCharacter(edynSelect.isChecked());

    TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
    style.font = gameProcessor.getAssetManager().get(AssetsUtil.NEUROPOL_32, AssetsUtil.BITMAP_FONT);
    style.fontColor = Color.CYAN;

    TextButton credits = new TextButton("BG Music By DST under Creative Commons License", style);

    credits.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Gdx.net.openURI("http://creativecommons.org/licenses/by/3.0/legalcode");
            Gdx.net.openURI("http://www.nosoapradio.us/");
        }
    });
    credits.setPosition(optionsGroup.getWidth() / 2 - (credits.getWidth() / 2), 0f);
    optionsGroup.addActor(credits);
}

From source file:com.maplescot.loggerbill.misc.Profile.java

License:Creative Commons License

public void save(Preferences prefs) {
    ckSum = makeCkSum();//from  w  w  w .j av  a2 s . co m
    ckSumV = ckVersion;
    prefs.putBoolean(soundOnStr, soundOn);
    prefs.putBoolean(musicOnStr, musicOn);
    prefs.putLong(totalPlaysStr, totalPlays);
    prefs.putLong(totalChunksStr, totalChunks);
    prefs.putLong(totalTimeStr, totalTime);
    prefs.putLong(bestChunksStr, bestChunks);
    prefs.putFloat(bestCPSStr, bestCPS);
    prefs.putString(gplusStr, gplusId);
    prefs.putString(CKSUM, ckSum);
    prefs.putLong(CKSUMV, ckSumV);

    prefs.putString(achievementsStr, saveAchievements());
}

From source file:com.redthirddivision.astilade.entities.mobs.Player.java

License:Apache License

public static void savePlayer(Player player) {
    LogHelper.info("Saving player data");
    Preferences prefs = Gdx.app.getPreferences(Astilade.TITLE);
    prefs.putFloat("playerX", player.position.x);
    prefs.putFloat("playerY", player.position.y);

    prefs.flush();/*  ww  w . j av  a2  s  .  c o m*/
    LogHelper.info("Player data saved");
}