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

The following examples show how to use com.badlogic.gdx.Preferences#putBoolean() . 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 storeConfiguration() {
    Preferences prefs = Gdx.app.getPreferences("sif_train_config");
    prefs.putInteger("offset", offset);
    prefs.putInteger("input_offset", inputOffset);
    prefs.putInteger("song_vol", songVolume);
    prefs.putInteger("feedback_vol", feedbackVolume);
    prefs.putString("path_to_beatmaps", pathToBeatmaps);
    prefs.putBoolean("play_hint_sounds", playHintSounds);
    prefs.putInteger("note_speed", noteSpeed);
    prefs.putInteger("overall_difficulty", overallDifficulty);
    prefs.putInteger("sorting_mode", sortMode);
    prefs.putInteger("random_mode", randomMode);
    prefs.putInteger("sorting_order", sortOrder);
    prefs.putInteger("sync_mode", syncMode);
    prefs.flush();
}
 
Example 2
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 3
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 4
Source File: AudioUtils.java    From martianrun with Apache License 2.0 4 votes vote down vote up
private void saveBoolean(String key, boolean value) {
    Preferences preferences = getPreferences();
    preferences.putBoolean(key, value);
    preferences.flush();
}
 
Example 5
Source File: State.java    From FruitCatcher with Apache License 2.0 4 votes vote down vote up
public static void setSoundOn(boolean on) {
	Preferences prefs = Gdx.app.getPreferences(preferencesName);
	prefs.putBoolean("SoundOn", on);
	prefs.flush();
}
 
Example 6
Source File: State.java    From FruitCatcher with Apache License 2.0 4 votes vote down vote up
public static void unLockLevel(int level) {
	Preferences prefs = Gdx.app.getPreferences(preferencesName);
	prefs.putBoolean("Level" + (level + 1), true);
	prefs.flush();		
}
 
Example 7
Source File: Toggleable.java    From gdx-proto with Apache License 2.0 4 votes vote down vote up
public static void saveToPrefs() {
	Preferences p = getPrefs();
	p.putBoolean(DEBUG_DRAW, Toggleable.getValue(DEBUG_DRAW));
	p.putBoolean(PROFILE_GL, Toggleable.getValue(PROFILE_GL));
	p.flush();
}