Java Code Examples for com.badlogic.gdx.Preferences#getBoolean()

The following examples show how to use com.badlogic.gdx.Preferences#getBoolean() . 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: GlobalConfiguration.java    From SIFTrain with MIT License 6 votes vote down vote up
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 2
Source File: DicePreferences.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
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 3
Source File: State.java    From FruitCatcher with Apache License 2.0 5 votes vote down vote up
public static boolean isLevelUnlocked(int level) {
	if (level == 0) {
		return true;
	}
	Preferences prefs = Gdx.app.getPreferences(preferencesName);
	return prefs.getBoolean("Level" + (level + 1));		
}
 
Example 4
Source File: MainMenu.java    From libgdx-demo-pax-britannica with MIT License 4 votes vote down vote up
@Override
public void show() {	
	Resources.getInstance().reInit();

	GameInstance.getInstance().resetGame();
	
	changeToScreen = -1;
	
	backgroundFX = new BackgroundFXRenderer();
	
	title = Resources.getInstance().title;
	credits = Resources.getInstance().credits;
	settings = Resources.getInstance().settings;
	blackFade = Resources.getInstance().blackFade;
	
	musicOnOff = Resources.getInstance().musicOnOff;
	musicOnOff.setPosition(20, 10);
	musicOnOff.setColor(1,1,1,0.5f);
	collisionMusic.set(new Vector3(musicOnOff.getVertices()[0], musicOnOff.getVertices()[1], -10),new Vector3(musicOnOff.getVertices()[10], musicOnOff.getVertices()[11], 10));
	
	help = Resources.getInstance().help;
	help.setPosition(75, 10);
	help.setColor(1,1,1,0.5f);
	collisionHelp.set(new Vector3(help.getVertices()[0], help.getVertices()[1], -10),new Vector3(help.getVertices()[10], help.getVertices()[11], 10));
	
	settings = Resources.getInstance().settings;
	settings.setPosition(135, 8);
	settings.setColor(1,1,1,0.5f);
	collisionSettings.set(new Vector3(settings.getVertices()[0], settings.getVertices()[1], -10),new Vector3(settings.getVertices()[10], settings.getVertices()[11], 10));
	
	p1 = new FactorySelector(new Vector2(055f, 150f), 1);
	p2 = new FactorySelector(new Vector2(180f, 150f), 2);
	p3 = new FactorySelector(new Vector2(305f, 150f), 3);
	p4 = new FactorySelector(new Vector2(430f, 150f), 4);

	countdown = new Countdown(new Vector2(380f, 7f));

	titleBatch = new SpriteBatch();
	titleBatch.getProjectionMatrix().setToOrtho2D(0, 0, 800, 480);
	fadeBatch = new SpriteBatch();
	fadeBatch.getProjectionMatrix().setToOrtho2D(0, 0, 2, 2);
	
	Preferences prefs = Gdx.app.getPreferences("paxbritannica");
	if(prefs.getBoolean("music") == true) { 
		if(Resources.getInstance().music == null) Resources.getInstance().reInit();
		if(!Resources.getInstance().music.isPlaying()) { 
			Resources.getInstance().music.play();
			Resources.getInstance().music.setLooping(true);
		}
		musicOnOff.setColor(1,1,1,0.5f);
	} else {
		Resources.getInstance().music.stop();			
		musicOnOff.setColor(1,1,1,0.1f);
	}
	
}
 
Example 5
Source File: MainMenu.java    From libgdx-demo-pax-britannica with MIT License 4 votes vote down vote up
@Override
public boolean keyDown(int keycode) {
	if(keycode == Input.Keys.BACK || keycode == Input.Keys.ESCAPE) {
		boolean exit = true;
		if(p1.picked) {
			p1.reset();
			exit = false;
		}
		if(p2.picked) {
			p2.reset();
			exit = false;
		}			
		if(p3.picked) {
			p3.reset();
			exit = false;
		}			
		if(p4.picked) {
			p4.reset();
			exit = false;
		}
		
		if(exit) {
			if(!(Gdx.app.getType() == ApplicationType.Applet)) {
				Gdx.app.exit();
			}
		}
	}
	
	if(keycode == Input.Keys.A) {
		if (!p1.picked) {
			p1.picked = true;
		} else {
			p1.playerSelect = true;
			p1.cpuSelect = false;
		}			
	}		
	if(keycode == Input.Keys.F) {
		if (!p2.picked) {
			p2.picked = true;
		}  else {
			p2.playerSelect = true;
			p2.cpuSelect = false;
		}	
	}		
	if(keycode == Input.Keys.H) {
		if (!p3.picked) {
			p3.picked = true;
		}  else {
			p3.playerSelect = true;
			p3.cpuSelect = false;
		}	
	}
	if(keycode == Input.Keys.L) {
		if (!p4.picked) {
			p4.picked = true;
		}  else {
			p4.playerSelect = true;
			p4.cpuSelect = false;
		}	
	}
	
	if(keycode == Input.Keys.M) {
		if (cnt >= 1)
			return false;
		Preferences prefs = Gdx.app.getPreferences("paxbritannica");
		prefs.putBoolean("music", !prefs.getBoolean("music"));
		prefs.flush();
		if(prefs.getBoolean("music")) {
			if(Resources.getInstance().music == null) Resources.getInstance().reInit();
			if(!Resources.getInstance().music.isPlaying()) { 
				Resources.getInstance().music.play();
				Resources.getInstance().music.setLooping(true);
			}
			musicOnOff.setColor(1,1,1,0.5f);				
		} else {
			Resources.getInstance().music.stop();
			musicOnOff.setColor(1,1,1,0.1f);
		}			
	}
	
	if(keycode == Input.Keys.F1) {
		if (cnt >= 1)
			return false;
		countdown.finished = true;
		changeToScreen = 0;
	}
	
	if(keycode == Input.Keys.S) {
		if (cnt >= 1)
			return false;
		countdown.finished = true;
		changeToScreen = 1;
	}
			

	return false;
}
 
Example 6
Source File: MainMenu.java    From libgdx-demo-pax-britannica with MIT License 4 votes vote down vote up
@Override
public boolean touchDown(int x, int y, int pointer, int button) {

	collisionRay = cam.getPickRay(x, y);
	
	if (cnt > 4 || countdown.finished)
		return false;	
	
	// check if ship is activated
	if (Intersector.intersectRayBoundsFast(collisionRay, p1.collision) && !p1.picked) {
		p1.picked = true;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p2.collision) && !p2.picked) {
		p2.picked = true;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p3.collision) && !p3.picked) {
		p3.picked = true;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p4.collision) && !p4.picked) {
		p4.picked = true;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p1.collisionPlayerSelect) && p1.picked && !p1.cpuSelect) {
		p1.playerSelect = true;
		p1.cpuSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p2.collisionPlayerSelect) && p2.picked && !p2.cpuSelect) {
		p2.playerSelect = true;
		p2.cpuSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p3.collisionPlayerSelect) && p3.picked && !p3.cpuSelect) {
		p3.playerSelect = true;
		p3.cpuSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p4.collisionPlayerSelect) && p4.picked && !p4.cpuSelect) {
		p4.playerSelect = true;
		p4.cpuSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p1.collisionCPUSelect) && p1.picked && !p1.playerSelect) {
		p1.cpuSelect = true;
		p1.playerSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p2.collisionCPUSelect) && p2.picked && !p2.playerSelect) {
		p2.cpuSelect = true;
		p2.playerSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p3.collisionCPUSelect) && p3.picked && !p3.playerSelect) {
		p3.cpuSelect = true;
		p3.playerSelect = false;
	} else if (Intersector.intersectRayBoundsFast(collisionRay, p4.collisionCPUSelect) && p4.picked && !p4.playerSelect) {
		p4.cpuSelect = true;
		p4.playerSelect = false;
	}
	
	if (Intersector.intersectRayBoundsFast(collisionRay, collisionMusic)) {
		if (cnt >= 1)
			return false;
		Preferences prefs = Gdx.app.getPreferences("paxbritannica");
		prefs.putBoolean("music", !prefs.getBoolean("music"));
		prefs.flush();
		if(prefs.getBoolean("music")) {
			if(Resources.getInstance().music == null) Resources.getInstance().reInit();
			if(!Resources.getInstance().music.isPlaying()) { 
				Resources.getInstance().music.play();
				Resources.getInstance().music.setLooping(true);
			}
			musicOnOff.setColor(1,1,1,0.5f);				
		} else {
			Resources.getInstance().music.stop();
			musicOnOff.setColor(1,1,1,0.1f);
		}			
	}
	
	if (Intersector.intersectRayBoundsFast(collisionRay, collisionHelp)) {
		if (cnt >= 1)
			return false;
		countdown.finished = true;
		changeToScreen = 0;
	}
	
	if (Intersector.intersectRayBoundsFast(collisionRay, collisionSettings)) {
		if (cnt >= 1)
			return false;
		countdown.finished = true;
		changeToScreen = 1;
	}
	
	return false;
}
 
Example 7
Source File: State.java    From FruitCatcher with Apache License 2.0 4 votes vote down vote up
public static boolean isSoundOn() {
	Preferences prefs = Gdx.app.getPreferences(preferencesName);
	return prefs.getBoolean("SoundOn");
}