List of usage examples for com.badlogic.gdx Preferences putInteger
public Preferences putInteger(String key, int val);
From source file:com.a2client.Config.java
License:Open Source License
public static void SaveOptions() { // Preferences p = getPrefs(); Preferences p = Gdx.app.getPreferences(CONFIG_FILE); p.putInteger("window_width", WindowWidth); p.putInteger("window_height", WindowHeight); p.putInteger("screen_width", ScreenWidth_to_save); p.putInteger("screen_height", ScreenHeight_to_save); p.putInteger("frame_rate", FrameFate); p.putBoolean("use_vsync", vSync); p.putBoolean("reduce_bg", ReduceInBackground); p.putBoolean("start_fullscreen", isFullscreen); // AppSettings.put("sound_enabled", SoundEnabled); // AppSettings.put("sound_vol", SoundVolume); // AppSettings.put("music_vol", MusicVolume); // AppSettings.put("debug_engine", DebugEngine); p.putString("language", current_lang); // AppSettings.put("count_objs", count_objs); // AppSettings.put("hide_overlapped", hide_overlapped); // AppSettings.put("move_inst_left_mouse", move_inst_left_mouse); // AppSettings.put("zoom_by_wheel", zoom_by_wheel); // AppSettings.put("zoom_over_mouse", zoom_over_mouse); // AppSettings.put("fullscreen_alt_enter", fullscreen_alt_enter); // AppSettings.put("minimap_draw_objects", minimap_draw_objects); p.putString("account", account); if (save_pass) { p.putString("password", password); } else {/*from w w w.j a v a 2 s . com*/ p.putString("password", ""); } p.putBoolean("save_pass", save_pass); p.flush(); }
From source file:com.agateau.ui.GamepadInputMapper.java
License:Open Source License
@Override public void saveConfig(Preferences preferences, String prefix) { preferences.putInteger(prefix + TRIGGER_BUTTON_PREF, mButtonCodes.get(GamepadButton.TRIGGER)); preferences.putInteger(prefix + BACK_BUTTON_PREF, mButtonCodes.get(GamepadButton.BACK)); }
From source file:com.gamestudio24.martianrun.utils.GameManager.java
License:Apache License
public void saveScore(int score) { Preferences preferences = getPreferences(); int maxScore = preferences.getInteger(MAX_SCORE_PREFERENCE, 0); if (score > maxScore) { preferences.putInteger(MAX_SCORE_PREFERENCE, score); preferences.flush();//from w w w . j a va2 s.c o m } }
From source file:com.gamestudio24.martianrun.utils.GameManager.java
License:Apache License
public void incrementAchievementCount(String id, int steps) { Preferences preferences = getPreferences(); int count = preferences.getInteger(getAchievementCountId(id), 0); count += steps;//from ww w.j a va 2 s.c om preferences.putInteger(getAchievementCountId(id), count); preferences.flush(); }
From source file:com.kasetagen.game.bubblerunner.screen.BubbleRunnerMenu.java
License:Creative Commons License
private void assembleHighScoreView(TextureAtlas atlas) { GenericActor highScoreScaffold = new GenericActor(0f, 0f, stage.getWidth(), stage.getHeight(), atlas.findRegion(AtlasUtil.ANI_HIGH_SCORE_BG), Color.BLACK); highScoreGroup.addActor(highScoreScaffold); /*/* w w w . jav a2s . com*/ * Add Labels */ Label.LabelStyle style = new Label.LabelStyle(); style.font = gameProcessor.getAssetManager().get(AssetsUtil.NEUROPOL_64, AssetsUtil.BITMAP_FONT); highScoreLabel = new Label("High Score: " + UIUtil.convertIntToDigitsString(GameStats.MAX_SCORE_DIGITS, 0), style); highComboLabel = new Label("High Combo: " + UIUtil.convertIntToDigitsString(GameStats.MAX_COMBO_DIGITS, 0), style); adjustHighScores(scoreValue, comboValue); highScoreGroup.addActor(highScoreLabel); highScoreGroup.addActor(highComboLabel); /* * Add Clear Button */ TextButton.TextButtonStyle tbStyle = new TextButton.TextButtonStyle(); tbStyle.font = gameProcessor.getAssetManager().get(AssetsUtil.NEUROPOL_64, AssetsUtil.BITMAP_FONT); tbStyle.fontColor = Color.WHITE; tbStyle.downFontColor = Color.CYAN; float tbXPadding = 100f; float tbYPadding = 50f; clearScoresButton = new TextButton("Clear Scores", tbStyle); clearScoresButton.addListener(new ClickListener() { IDataSaver scoreClearer = new IDataSaver() { @Override public void updatePreferences(Preferences preferences) { preferences.putInteger(GameStats.HIGH_SCORE_KEY, 0); preferences.putInteger(GameStats.HIGH_COMBO_KEY, 0); preferences.putInteger(GameStats.MOST_MISSES_KEY, 0); } }; @Override public void clicked(InputEvent event, float x, float y) { gameProcessor.saveGameData(scoreClearer); adjustHighScores(0, 0); } }); clearScoresButton.setPosition(tbXPadding, tbYPadding); highScoreGroup.addActor(clearScoresButton); /* * Add Main Menu Button */ Array<TextureAtlas.AtlasRegion> mmImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_MAINMENU); TextureRegionDrawable mmDown = new TextureRegionDrawable(mmImgs.get(1)); closeScoresButton = new TextButton("Main Menu", tbStyle); //closeScoresButton.setSize(300f, 100f); closeScoresButton.setPosition(highScoreGroup.getWidth() - (closeScoresButton.getWidth() + tbXPadding), tbYPadding); closeScoresButton.addListener(listener); highScoreGroup.addActor(closeScoresButton); }
From source file:com.theosirian.ppioo.util.GameData.java
License:Open Source License
public GameData save() { Preferences state = Gdx.app.getPreferences(saveName); for (Player player : players) { if (player.isOwned()) { String key = "player-" + player.getId(); state.putBoolean(key, true); state.putLong(key + "-date_acquired", player.getDateAcquired().getTime()); state.putInteger(key + "-victories", player.getVictories()); state.putInteger(key + "-defeats", player.getDefeats()); }//from w ww .j a v a 2s .co m } for (Fan fan : fans) { if (fan.isOwned()) { String key = "fan-" + fan.getId(); state.putBoolean(key, true); state.putLong(key + "-date_acquired", fan.getDateAcquired().getTime()); state.putInteger(key + "-victories", fan.getVictories()); state.putInteger(key + "-defeats", fan.getDefeats()); } } state.putInteger("money", money); state.putInteger("victories", victories); state.putInteger("defeats", defeats); state.flush(); return this; }
From source file:edu.lehigh.cse.lol.Facts.java
License:Open Source License
/** * Save a fact about the current game session. If the factName has already * been used for this game session, the new value will overwrite the old. * * @param factName The name for the fact being saved * @param factValue The integer value that is the fact being saved *///from www . j a v a 2s . c om public static void putGameFact(String factName, int factValue) { Preferences prefs = Gdx.app.getPreferences(Lol.sGame.mStorageKey); prefs.putInteger(factName, factValue); prefs.flush(); }
From source file:headmade.arttag.screens.IntroScreen.java
License:Apache License
@Override public void preDraw(float delta) { super.preDraw(delta); if (!isInitialised) { Gdx.app.log(TAG, "Loading Prefs"); isInitialised = true;/* w w w. jav a2 s. com*/ ArtTag.gameSettings = new GameSettings(); final Preferences prefs = Gdx.app.getPreferences("ArtTreacheryPrefs"); ArtTag.gameSettings.screenWidth = prefs.getInteger("screenWidth", 1280); ArtTag.gameSettings.screenHeight = prefs.getInteger("screenHeight", 1024); ArtTag.gameSettings.fullscreen = prefs.getBoolean("fullscreen", false); ArtTag.gameSettings.blur = prefs.getInteger("blur", 1); ArtTag.gameSettings.rays = prefs.getInteger("rays", 64); ArtTag.gameSettings.handleResAuto = prefs.getBoolean("handleResAuto", true); Gdx.app.log(TAG, "Saving Prefs"); prefs.putInteger("screenWidth", ArtTag.gameSettings.screenWidth); prefs.putInteger("screenHeight", ArtTag.gameSettings.screenHeight); prefs.putBoolean("fullscreen", ArtTag.gameSettings.fullscreen); prefs.putInteger("blur", ArtTag.gameSettings.blur); prefs.putInteger("rays", ArtTag.gameSettings.rays); prefs.putBoolean("handleResAuto", ArtTag.gameSettings.handleResAuto); prefs.flush(); if (Gdx.graphics.supportsDisplayModeChange() && ArtTag.gameSettings.handleResAuto == false) { Gdx.app.log(TAG, "Trying to set Displaymode"); Gdx.graphics.setDisplayMode(ArtTag.gameSettings.screenWidth, ArtTag.gameSettings.screenHeight, ArtTag.gameSettings.fullscreen); // Gdx.gl.glViewport(0, 0, ArtTag.gameSettings.screenWidth, ArtTag.gameSettings.screenHeight); } } Assets.assetsManager.update(); if (!isStarted && MathUtils.isEqual(1f, Assets.assetsManager.getProgress())) { // done loading eh Assets.instance.onFinishLoading(); startGame(); isStarted = true; // final TextButton startButton = new TextButton("Start", Assets.instance.skin); // startButton.addListener(new InputListener() { // // @Override // public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { // startGame(); // return super.touchDown(event, x, y, pointer, button); // } // }); } }
From source file:io.github.deathsbreedgames.spacerun.screens.GameOverScreen.java
public GameOverScreen(AssetManager manager) { super("MainMenu", manager); Preferences prefs = Gdx.app.getPreferences("SpaceRun"); // Set high score if (GlobalVars.score > GlobalVars.highScore) { GlobalVars.highScore = GlobalVars.score; prefs.putInteger("HighScore", GlobalVars.highScore); if (Gdx.app.getType() == ApplicationType.Android && GlobalVars.actionResolver.getSignedInGPGS()) { GlobalVars.actionResolver.submitScoreGPGS(GlobalVars.highScore); }// ww w .j a v a2 s. c o m } prefs.putInteger("KillCount", GlobalVars.killCount); prefs.flush(); // Setup draw camera = new OrthographicCamera(GlobalVars.width, GlobalVars.height); camera.position.set(GlobalVars.width / 2, GlobalVars.height / 2, 0f); camera.update(); batch = new SpriteBatch(); font = new BitmapFont(); font.scale(0.5f); // Setup buttons mainStage = new Stage(new StretchViewport(GlobalVars.width, GlobalVars.height)); buttonAtlas = manager.get("gfx/ui/buttons.pack", TextureAtlas.class); buttonSkin = new Skin(buttonAtlas); Gdx.input.setInputProcessor(mainStage); buttonFont = new BitmapFont(); buttonFont.scale(0.3f); TextButtonStyle buttonStyle = new TextButtonStyle(); buttonStyle.up = buttonSkin.getDrawable("MainMenu-normal"); buttonStyle.down = buttonSkin.getDrawable("MainMenu-down"); buttonStyle.over = buttonSkin.getDrawable("MainMenu-hover"); buttonStyle.font = buttonFont; TextButton menuButton = new TextButton(GlobalVars.gameBundle.get("mainmenu"), buttonStyle); menuButton.setPosition(GlobalVars.width / 2 - menuButton.getWidth() / 2, 10f); mainStage.addActor(menuButton); menuButton.addListener(new ChangeListener() { public void changed(ChangeEvent e, Actor a) { setNextScreen("MainMenu"); setDone(true); } }); }