本文整理汇总了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();
}