本文整理匯總了Java中com.badlogic.gdx.Preferences.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.flush方法的具體用法?Java Preferences.flush怎麽用?Java Preferences.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.Preferences
的用法示例。
在下文中一共展示了Preferences.flush方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveWindowParams
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
private void saveWindowParams() {
int width = Display.getWidth();
int height = Display.getHeight();
int x = Display.getX();
int y = Display.getY();
//FIXME by some reason actual window position shifted by 6 pixels on Windows (by 12 at y when maximized)
if (LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS) {
x += 6;
y += 6;
}
Preferences prefs = Gdx.app.getPreferences("window_params.xml");
prefs.putInteger("x", x);
prefs.putInteger("y", y);
prefs.putInteger("width", width);
prefs.putInteger("height", height);
prefs.flush();
}
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:20,代碼來源:WindowParamsPersistingApplicationWrapper.java
示例2: data
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
void data()
{
//get a preferences instance
Preferences prefs = Gdx.app.getPreferences("My Preferences");
highScore=prefs.getInteger("score", 0);
if(score>highScore)
{
//put some Integer
prefs.putInteger("score", score);
//persist preferences
prefs.flush();
}
//get Integer from preferences, 0 is the default value.
highScore=prefs.getInteger("score", 0);
}
示例3: moveAutosaveKeyToFirstPlace
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public void moveAutosaveKeyToFirstPlace() {
if (!containsKey(AUTOSAVE_KEY, SAVE_SLOT_PREFS)) return;
ArrayList<String> keys = getKeys(SAVE_SLOT_PREFS);
keys.remove(AUTOSAVE_KEY);
keys.add(0, AUTOSAVE_KEY);
StringBuilder newKeys = new StringBuilder();
for (String key : keys) {
newKeys.append(key).append(" ");
}
Preferences preferences = getPreferences(SAVE_SLOT_PREFS);
preferences.putString("keys", newKeys.toString());
preferences.flush();
}
示例4: storeConfiguration
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public static void storeConfiguration() {
Preferences prefs = Gdx.app.getPreferences("ss_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.putBoolean("display_line", displayLine);
prefs.putInteger("sorting_mode", sortMode);
prefs.putInteger("sorting_order", sortOrder);
prefs.putInteger("sync_mode", syncMode);
prefs.flush();
}
示例5: storeConfiguration
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
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();
}
示例6: saveScoreEtc
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public void saveScoreEtc() {
Preferences prefs = Gdx.app.getPreferences(GameSaves);
// sum of all scores ever
totalScoreSum += currentScore;
prefs.putInteger("total_score_sum", totalScoreSum);
// games played by player
++totalGamesPlayed;
prefs.putInteger("total_games_played", totalGamesPlayed);
// save top score
if (topScore < currentScore) {
topScore = currentScore;
// Save top score!!!!
prefs.putInteger("topscore", topScore);
}
// hack / dont want to kill my ssd
if (Gdx.app.getType() != ApplicationType.Desktop) {
prefs.flush();
}
}
示例7: saveConfiguration
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public void saveConfiguration() {
Preferences buttonIndexToKeyCodePreferences = Gdx.app.getPreferences(BUTTON_INDEX_TO_KEY_CODE_PREFERENCES);
Preferences buttonIndexToButtonPreferences = Gdx.app.getPreferences(BUTTON_INDEX_TO_BUTTON_PREFERENCES);
buttonIndexToKeyCodePreferences.clear();
buttonIndexToButtonPreferences.clear();
for(com.gradualgames.ggvm.Controller.Buttons button: com.gradualgames.ggvm.Controller.Buttons.values()) {
if (button.isConfigurable()) {
if (buttonIndexToKeyCode.containsKey(button)) {
buttonIndexToKeyCodePreferences.putInteger(button.name(), buttonIndexToKeyCode.get(button));
}
if (buttonIndexToButton.containsKey(button)) {
buttonIndexToButtonPreferences.putInteger(button.name(), buttonIndexToButton.get(button));
}
}
}
buttonIndexToKeyCodePreferences.flush();
buttonIndexToButtonPreferences.flush();
Preferences actualAxisToAxisCodePreferences = Gdx.app.getPreferences(ACTUAL_AXIS_TO_AXIS_CODE_PREFERENCES);
actualAxisToAxisCodePreferences.clear();
for(Axis axis: Axis.values()) {
if (actualAxisToAxisCode.containsKey(axis)) {
actualAxisToAxisCodePreferences.putInteger(axis.name(), actualAxisToAxisCode.get(axis));
}
}
actualAxisToAxisCodePreferences.flush();
}
示例8: pause
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
@Override
public void pause() {
Preferences prefs = Gdx.app.getPreferences("MyPreferences");
prefs.putInteger("level", level);
prefs.putInteger("score", score);
prefs.putInteger("maxscore", maxscore);
prefs.putInteger("movements", movements);
prefs.putInteger("maxmovements", maxmovements);
prefs.flush();
}
示例9: InitPreferences
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public void InitPreferences()
{
Preferences prefs = Gdx.app.getPreferences("MyPreferences");
if(!prefs.contains("sound"))
{
prefs.putBoolean("sound",true);
prefs.flush();
}
}
示例10: setUserName
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public static void setUserName(String name) {
Preferences prefs = Gdx.app.getPreferences(PREFERENCES_NAME);
// make sure the name is correct
if (name.length() < MIN_NAME_LENGTH) {
name = name + "---";
} else if (name.length() > MAX_NAME_LENGTH){
name += name.substring(0, MAX_NAME_LENGTH - 1);
}
prefs.putString(PREFERENCES_USER_NAME, name.trim());
prefs.flush();
}
示例11: setMaxLevel
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public void setMaxLevel(int section, int newMaxLevel) {
newMaxLevel = Math.min(newMaxLevel, Constants.LEVEL_LIST[section].length);
if (maxLevel[section] < newMaxLevel) {
maxLevel[section] = newMaxLevel;
Preferences prefs = Gdx.app.getPreferences(Constants.PREFERENCES);
prefs.putInteger("maxlevel_" + section, newMaxLevel);
prefs.flush();
}
}
示例12: setStars
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
public void setStars(int section, int level, int stars) {
int oldStars = getStars(section, level);
if (oldStars < stars) {
Preferences prefs = Gdx.app.getPreferences(Constants.PREFERENCES);
prefs.putInteger("stars_" + section + "_" + level, stars);
prefs.flush();
int treasure = getTreasure();
setTreasure(treasure + stars - oldStars);
}
}
示例13: createFont
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
/**
* Will load font from file. If that fails, font will be generated and saved
* to file.
*
* @param fontFile
* the actual font (.otf, .ttf)
* @param fontName
* the name of the font, i.e. "arial-small", "arial-large",
* "monospace-10" This will be used for creating the font file
* names
* @param fontSize
* size of font when screen width equals referenceScreenWidth
*
* @return created bitmap fonts object
*/
public BitmapFont createFont(FileHandle fontFile, String fontName, int fontSize) {
BitmapFont font = null;
// if fonts are already generated, just load from file
Preferences fontPrefs = Gdx.app.getPreferences("org.jrenner.smartfont");
int displayWidth = fontPrefs.getInteger("display-width", 0);
int displayHeight = fontPrefs.getInteger("display-height", 0);
boolean loaded = false;
if (displayWidth != Gdx.graphics.getWidth() || displayHeight != Gdx.graphics.getHeight()) {
Gdx.app.debug(TAG, "Screen size change detected, regenerating fonts");
} else {
try {
// try to load from file
Gdx.app.debug(TAG, "Loading generated font from file cache");
font = new BitmapFont(getFontFile(fontName + ".fnt"));
loaded = true;
} catch (GdxRuntimeException e) {
Gdx.app.error(TAG, e.getMessage());
Gdx.app.debug(TAG, "Couldn't load pre-generated fonts. Will generate fonts.");
}
}
if (!loaded || forceGeneration) {
forceGeneration = false;
float width = Gdx.graphics.getWidth();
float ratio = width / referenceScreenWidth; // use 1920x1280 as
// baseline, arbitrary
float baseSize = 28f; // for 28 sized fonts at baseline width above
// store screen width for detecting screen size change
// on later startups, which will require font regeneration
fontPrefs.putInteger("display-width", Gdx.graphics.getWidth());
fontPrefs.putInteger("display-height", Gdx.graphics.getHeight());
fontPrefs.flush();
font = generateFontWriteFiles(fontName, fontFile, fontSize, pageSize, pageSize);
}
return font;
}
示例14: saveSettings
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
/**
* Save the settings for this profile
*/
public final void saveSettings() {
int myCRC=0;
Preferences prefsEditor = Gdx.app.getPreferences(fileName);
// save settings and preferences
prefsEditor.putBoolean("usemusic", useMusic);
prefsEditor.putBoolean("usesfx", useSFX);
prefsEditor.putBoolean("useFullscreen",useFullscreen);
prefsEditor.putInteger("storedWindowedModeID",storedWindowedModeID);
prefsEditor.putInteger("musicvolume",musicVolume);
prefsEditor.putInteger("soundvolume",soundVolume);
for (int i=6; --i>=0;) {
prefsEditor.putInteger("stickx"+i,stickX[i]);
prefsEditor.putInteger("sticky"+i,stickY[i]);
}
for (int i=16; --i>=0;) {
prefsEditor.putInteger("keyboardSettings"+i,keyboardSettings[i]);
}
for (int i=12; --i>=0;) {
prefsEditor.putInteger("controller1"+i,controller1[i]);
prefsEditor.putInteger("controller2"+i,controller2[i]);
}
prefsEditor.putInteger("LastMinuteEvent", myCRC);
prefsEditor.flush();
prefsEditor=null;
}
示例15: save
import com.badlogic.gdx.Preferences; //導入方法依賴的package包/類
private void save() {
Preferences preferences = getPreferences();
preferences.putInteger("accept_early_game_end", acceptedEarlyGameEnd);
preferences.putInteger("refuse_early_game_end", refusedEarlyGameEnd);
preferences.flush();
}