Java Code Examples for com.badlogic.gdx.Preferences#getInteger()
The following examples show how to use
com.badlogic.gdx.Preferences#getInteger() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameOverScreen.java From libgdx-2d-tutorial with MIT License | 6 votes |
public GameOverScreen (SpaceGame game, int score) { this.game = game; this.score = score; //Get highscore from save file Preferences prefs = Gdx.app.getPreferences("spacegame"); this.highscore = prefs.getInteger("highscore", 0); //Check if score beats highscore if (score > highscore) { prefs.putInteger("highscore", score); prefs.flush(); } //Load textures and fonts gameOverBanner = new Texture("game_over.png"); scoreFont = new BitmapFont(Gdx.files.internal("fonts/score.fnt")); game.scrollingBackground.setSpeedFixed(true); game.scrollingBackground.setSpeed(ScrollingBackground.DEFAULT_SPEED); }
Example 2
Source File: FramePropertiesPersister.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
public static void loadFrameProperties(JFrame frame) { Preferences prefs = Gdx.app.getPreferences(PREF_NAME); DisplayMode displayMode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); int screenWidth = displayMode.getWidth(); int screenHeight = displayMode.getHeight(); int width = MathUtils.clamp(prefs.getInteger("width", frame.getSize().width), 320, screenWidth); int height = MathUtils.clamp(prefs.getInteger("height", frame.getSize().height), 320, screenHeight); int x = MathUtils.clamp(prefs.getInteger("x", frame.getLocation().x), 0, screenWidth - width); int y = MathUtils.clamp(prefs.getInteger("y", frame.getLocation().y), 0, screenHeight - height); int extendedState = prefs.getInteger("extendedState", frame.getExtendedState()); frame.setSize(width, height); frame.setLocation(x, y); frame.setExtendedState(extendedState); }
Example 3
Source File: KTXProcessor.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
protected File loadTempFilePath() { try { Preferences preferences = Gdx.app.getPreferences(PREFERENCES_FILE); int revision = preferences.getInteger(prefKeyFileRevision, -1); // Check if the revisions are the same if (this.fileRevision != revision) return null; String absolutePath = preferences.getString(prefKeyFilePath, null); if (absolutePath != null) { return new File(absolutePath); } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 4
Source File: KtxEtc2Processor.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
protected File loadTempFilePath() { try { Preferences preferences = Gdx.app.getPreferences(PREFERENCES_FILE); int revision = preferences.getInteger(prefKeyFileRevision, -1); // Check if the revisions are the same if (this.fileRevision != revision) return null; String absolutePath = preferences.getString(prefKeyFilePath, null); if (absolutePath != null) { return new File(absolutePath); } } catch (Exception e) { e.printStackTrace(); } return null; }
Example 5
Source File: GlobalConfiguration.java From SIFTrain with MIT License | 6 votes |
public static void loadConfiguration() { Preferences prefs = Gdx.app.getPreferences("sif_train_config"); offset = prefs.getInteger("offset", 0); inputOffset = prefs.getInteger("input_offset", 0); songVolume = prefs.getInteger("song_vol", 100); feedbackVolume = prefs.getInteger("feedback_vol", 100); pathToBeatmaps = prefs.getString("path_to_beatmaps", Gdx.files.getExternalStoragePath() + "beatmaps"); playHintSounds = prefs.getBoolean("play_hint_sounds", false); noteSpeed = prefs.getInteger("note_speed", 6); overallDifficulty = prefs.getInteger("overall_difficulty", 7); // default to song name sorting sortMode = prefs.getInteger("sorting_mode", SongUtils.SORTING_MODE_SONG_NAME); sortOrder = prefs.getInteger("sorting_order", SongUtils.SORTING_MODE_ASCENDING); // default to the new mode randomMode = prefs.getInteger("random_mode", SongUtils.RANDOM_MODE_NEW); // sync mode syncMode = prefs.getInteger("sync_mode", SongUtils.SYNC_MODE_1); }
Example 6
Source File: GameInstance.java From libgdx-demo-pax-britannica with MIT License | 6 votes |
public void resetGame() { fighters.clear(); factorys.clear(); bombers.clear(); frigates.clear(); bullets.clear(); bubbleParticles.dispose(); bigBubbleParticles.dispose(); sparkParticles.dispose(); explosionParticles.dispose(); bubbleParticles = new BubbleParticleEmitter(); bigBubbleParticles = new BigBubbleParticleEmitter(); sparkParticles = new SparkParticleEmitter(); explosionParticles = new ExplosionParticleEmitter(); Preferences prefs = Gdx.app.getPreferences("paxbritannica"); GameInstance.getInstance().difficultyConfig = prefs.getInteger("difficulty",0); GameInstance.getInstance().factoryHealthConfig = prefs.getInteger("factoryHealth",0); GameInstance.getInstance().antiAliasConfig = prefs.getInteger("antiAliasConfig",1); }
Example 7
Source File: DicePreferences.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public DicePreferences(Preferences preferences, App app) { this.preferences = preferences; this.app = app; volume = preferences.getFloat("volume", 0.5f); language = preferences.getString("language", Locale.getDefault().getLanguage()); scale = preferences.getInteger("scale", (int) ScreenHelper.scaleFor(Gdx.graphics.getWidth(), Gdx.app.getType() == Application.ApplicationType.Desktop)); rated = preferences.getBoolean("rated"); music = preferences.getBoolean("music", true); servicesPaneShownByDefault = preferences.getBoolean("services-pane", false); applyVolume(); applyMusic(); }
Example 8
Source File: onScreenControls.java From killingspree with MIT License | 5 votes |
public void resize() { Preferences prefs = Gdx.app.getPreferences("settings"); int scaling = prefs.getInteger("scaling"); if (scaling <= 30 || scaling >= 150) { scaling = 100; prefs.putInteger("scaling", 100); prefs.flush(); } float buttonSize = (BUTTON_SIZE * (float) Gdx.graphics.getWidth() * scaling) / (1280f * 100f); shootButton.setBounds(Gdx.graphics.getWidth() - buttonSize * 1.1f, buttonSize, buttonSize, buttonSize); jumpButton.setBounds(Gdx.graphics.getWidth() - 2 * buttonSize, 10, buttonSize, buttonSize); throwBombButton.setBounds(Gdx.graphics.getWidth() - buttonSize * 1.1f, 2f * buttonSize * 1.1f, buttonSize, buttonSize); closeButton.setBounds(Gdx.graphics.getWidth() - buttonSize * 1.1f, Gdx.graphics.getHeight() - buttonSize * 1.1f, buttonSize, buttonSize); buttonSize *= 0.8f; leftButton.setBounds(buttonSize * 0.1f, buttonSize * 0.1f, buttonSize, buttonSize); upButton.setBounds(buttonSize * 1.6f / 2, buttonSize, buttonSize, buttonSize); rightButton.setBounds(buttonSize * 1.6f, buttonSize * 0.1f, buttonSize, buttonSize); }
Example 9
Source File: GameManager.java From martianrun with Apache License 2.0 | 5 votes |
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(); } }
Example 10
Source File: GameManager.java From martianrun with Apache License 2.0 | 5 votes |
public void incrementAchievementCount(String id, int steps) { Preferences preferences = getPreferences(); int count = preferences.getInteger(getAchievementCountId(id), 0); count += steps; preferences.putInteger(getAchievementCountId(id), count); preferences.flush(); }