List of usage examples for com.badlogic.gdx Preferences contains
public boolean contains(String key);
From source file:at.juggle.games.memory.AssetManager.java
License:Apache License
public AssetManager(GameOptions options) { this.options = options; Preferences preferences = Gdx.app.getPreferences("memory_free_hd.prefs"); if (preferences.contains("soundOn")) { options.soundOn = preferences.getBoolean("soundOn"); }/*from w w w . j a v a2s.c o m*/ font = new BitmapFont(getFileHandle("berlin_64.fnt"), false); smallFont = new BitmapFont(getFileHandle("berlin_42.fnt"), false); card = new Texture(getFileHandle("card-front.png")); cardBack = new Texture(getFileHandle("card-back.png")); cardBackMark = new Texture(getFileHandle("card-back-mark.png")); check = new Texture(getFileHandle("Check_32x32.png")); positive = new Texture(getFileHandle("Positive_256x256.png")); grey = new Texture(getFileHandle("grey.png")); background = new Texture(getFileHandle("background.jpg")); gradientTop = new Texture(getFileHandle("gradient_oben.png")); gradientBottom = new Texture(getFileHandle("gradient_unten.png")); if (GameOptions.isFreeVersion) { logo = new Texture(getFileHandle("Logo.png")); } else { logo = new Texture(getFileHandle("Logo_donated.png")); } cardBack.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); cardBackMark.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); logo.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); Texture vehiclesTexture = new Texture(getFileHandle("vehicles.png")); vehiclesTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); TextureRegion[][] veh = TextureRegion.split(vehiclesTexture, 256, 256); icons = new TextureRegion[24]; icons[0] = new TextureRegion(loadTexture("animals/Butterfly_128x128.png")); icons[1] = new TextureRegion(loadTexture("animals/Dolphin_128x128.png")); icons[2] = new TextureRegion(loadTexture("animals/Elephant_128x128.png")); icons[3] = new TextureRegion(loadTexture("animals/Hippopotamus_128x128.png")); icons[4] = new TextureRegion(loadTexture("animals/Panda_128x128.png")); icons[5] = new TextureRegion(loadTexture("animals/Turtle_128x128.png")); icons[6] = new TextureRegion(loadTexture("vacation/surfboard_256x256.png")); icons[7] = new TextureRegion(loadTexture("vacation/umbrella_256x256.png")); int count = 0; for (int i = 0; i < veh.length; i++) { TextureRegion[] textureRegions = veh[i]; for (int j = 0; j < textureRegions.length; j++) { icons[8 + count] = textureRegions[j]; count++; } } // Particle effects fireworks = new ParticleEffect(); fireworks.load(getFileHandle("fireworks"), getFileHandle("")); // sounds sndFlipCard = Gdx.audio.newSound(getFileHandle("flipcard.ogg")); sndCheer = Gdx.audio.newSound(getFileHandle("drums.ogg")); sndDing = Gdx.audio.newSound(getFileHandle("ding.ogg")); }
From source file:at.therefactory.jewelthief.input.MenuScreenInputAdapter.java
License:Open Source License
@Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { super.touchUp(screenX, screenY, pointer, button); Preferences prefs = JewelThief.getInstance().getPreferences(); numTouches = Math.max(0, numTouches - 1); if (menuScreen.buttonExitToMainMenu.isPressed()) { menuScreen.buttonExitToMainMenu.release(); menuScreen.setShowLicenseYOffset(0); menuScreen.setState(MenuScreen.MenuState.ShowMenu); } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowAbout)) { if (menuScreen.buttonShowLicense.isPressed()) { menuScreen.buttonShowLicense.release(); if (menuScreen.getShowLicenseYOffset() == 0) { menuScreen.setShowLicenseYOffset(54); } else { menuScreen.setShowLicenseYOffset(0); }//ww w . j av a 2 s . co m } else if (menuScreen.buttonSoundtrack.isPressed()) { menuScreen.buttonSoundtrack.release(); Gdx.net.openURI(URL_TO_SOUNDTRACK); } else if (menuScreen.buttonRate.isPressed()) { menuScreen.buttonRate.release(); Gdx.net.openURI(URL_TO_PLAY_STORE); } } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowHighscores)) { if (menuScreen.buttonUpdateHighscores.isPressed()) { menuScreen.buttonUpdateHighscores.release(); menuScreen.setFetchingHighscores(true); HttpServer.fetchHighscores(menuScreen, prefs.getString(PrefsKeys.ID), prefs.getString(PrefsKeys.PLAYER_NAME), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_JEWELS), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_SECONDS)); } } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowSettings)) { if (menuScreen.buttonChangePlayername.isPressed()) { menuScreen.buttonChangePlayername.release(); Gdx.input.getTextInput(listener, bundle.get(PLEASE_ENTER_YOUR_NAME), prefs.getString(PrefsKeys.PLAYER_NAME), ""); } else if (menuScreen.buttonToggleSound.isPressed()) { menuScreen.buttonToggleSound.release(); menuScreen.buttonToggleSound.nextState(); prefs.putBoolean(PrefsKeys.ENABLE_SOUND, !prefs.getBoolean(PrefsKeys.ENABLE_SOUND)); prefs.flush(); } else if (menuScreen.buttonToggleMusic.isPressed()) { menuScreen.buttonToggleMusic.release(); menuScreen.buttonToggleMusic.nextState(); prefs.putBoolean(PrefsKeys.ENABLE_MUSIC, !prefs.getBoolean(PrefsKeys.ENABLE_MUSIC)); prefs.flush(); if (prefs.getBoolean(PrefsKeys.ENABLE_MUSIC)) { JewelThief.getInstance().playMusicFile(true); } else { JewelThief.getInstance().pauseMusic(); } } else if (menuScreen.buttonChangeLanguage.isPressed()) { menuScreen.buttonChangeLanguage.release(); menuScreen.buttonChangeLanguage.nextState(); bundle = JewelThief.getInstance() .setLocale(menuScreen.buttonChangeLanguage.getState() == 0 ? "en" : "de"); menuScreen.setBundle(bundle); } else if (menuScreen.buttonResetHighscore.isPressed()) { menuScreen.buttonResetHighscore.release(); if (timestampLastClickOnResetHighscoreSettingButton > System.currentTimeMillis() - 1000) { timestampLastClickOnResetHighscoreSettingButton = 0; prefs.remove(PrefsKeys.MY_RANK); prefs.remove(PrefsKeys.BEST_SCORE); prefs.remove(PrefsKeys.BEST_SCORE_NUM_JEWELS); prefs.remove(PrefsKeys.BEST_SCORE_NUM_SECONDS); JewelThief.getInstance().toast(bundle.get(HIGHSCORE_IS_RESET), true); } else { timestampLastClickOnResetHighscoreSettingButton = System.currentTimeMillis(); JewelThief.getInstance().toast(bundle.get(TAP_AGAIN_TO_RESET_HIGHSCORE), false); } } } // main menu else { if (menuScreen.buttonStartSinglePlayerGame.isPressed()) { JewelThief.getInstance().showIntroScreen(); menuScreen.buttonStartSinglePlayerGame.release(); } else if (menuScreen.buttonShowHighscores.isPressed()) { deltaY = 0; menuScreen.setScrollbarPositionY(Config.INITIAL_SCROLLBAR_POSITION_Y); if (prefs.contains(PrefsKeys.CACHED_HIGHSCORES)) { menuScreen.setHighscores(prefs.getString(PrefsKeys.CACHED_HIGHSCORES).split("\n")); } menuScreen.setState(MenuScreen.MenuState.ShowHighscores); menuScreen.buttonShowHighscores.release(); } else if (menuScreen.buttonShowSettings.isPressed()) { menuScreen.setState(MenuScreen.MenuState.ShowSettings); menuScreen.buttonShowSettings.release(); } else if (menuScreen.buttonShowAbout.isPressed()) { menuScreen.setState(MenuScreen.MenuState.ShowAbout); menuScreen.buttonShowAbout.release(); } } lastDeltaY = -deltaY; touchDragging = false; return true; }
From source file:at.therefactory.jewelthief.misc.Utils.java
License:Open Source License
/** * Returns a human readable string presenting the locally saved best score. * * @return//from ww w . j a v a 2 s.c o m */ public static String getBestScoreString() { Preferences prefs = JewelThief.getInstance().getPreferences(); if (prefs.contains(PrefsKeys.BEST_SCORE_NUM_JEWELS) && prefs.contains(PrefsKeys.BEST_SCORE_NUM_SECONDS)) return JewelThief.getInstance().getBundle().format(I18NKeys.YOUR_BEST_SCORE_IS, prefs.getInteger(PrefsKeys.BEST_SCORE), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_JEWELS), Utils.secondsToTimeString(prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_SECONDS))); else return ""; }
From source file:com.redthirddivision.astilade.screens.GameScreen.java
License:Apache License
@Override public void show() { super.show(); world = new World(100, 64); Preferences prefs = Gdx.app.getPreferences(Astilade.TITLE); physWorld = new PhysicsWorld(new Vector2(0, 0), true); boolean exists = prefs.contains("playerX"); if (exists && !newGame) { player = world.loadPlayer();//from w ww . j a va2s .c o m } else { LogHelper.info("Creating new player save data"); player = new Player(world, new Vector2(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2)); Player.savePlayer(player); } Enemy en = new DarkMage(world, new Vector2(600, 600)); Enemy en1 = new DarkMage(world, new Vector2(100, 200)); }