Search in sources :

Example 16 with Preferences

use of com.badlogic.gdx.Preferences in project libgdx by libgdx.

the class Lwjgl3Application method getPreferences.

@Override
public Preferences getPreferences(String name) {
    if (preferences.containsKey(name)) {
        return preferences.get(name);
    } else {
        Preferences prefs = new Lwjgl3Preferences(new Lwjgl3FileHandle(new File(config.preferencesDirectory, name), config.preferencesFileType));
        preferences.put(name, prefs);
        return prefs;
    }
}
Also used : Preferences(com.badlogic.gdx.Preferences) File(java.io.File)

Example 17 with Preferences

use of com.badlogic.gdx.Preferences in project libgdx by libgdx.

the class LwjglApplication method getPreferences.

@Override
public Preferences getPreferences(String name) {
    if (preferences.containsKey(name)) {
        return preferences.get(name);
    } else {
        Preferences prefs = new LwjglPreferences(new LwjglFileHandle(new File(preferencesdir, name), preferencesFileType));
        preferences.put(name, prefs);
        return prefs;
    }
}
Also used : Preferences(com.badlogic.gdx.Preferences) File(java.io.File)

Example 18 with Preferences

use of com.badlogic.gdx.Preferences in project libgdx by libgdx.

the class LwjglCanvas method getPreferences.

@Override
public Preferences getPreferences(String name) {
    if (preferences.containsKey(name)) {
        return preferences.get(name);
    } else {
        Preferences prefs = new LwjglPreferences(name, ".prefs/");
        preferences.put(name, prefs);
        return prefs;
    }
}
Also used : Preferences(com.badlogic.gdx.Preferences)

Example 19 with Preferences

use of com.badlogic.gdx.Preferences in project libgdx by libgdx.

the class PreferencesTest method create.

public void create() {
    Preferences prefs = Gdx.app.getPreferences(".test");
    if (prefs.contains("bool")) {
        if (prefs.getBoolean("bool") != true)
            throw new GdxRuntimeException("bool failed");
        if (prefs.getInteger("int") != 1234)
            throw new GdxRuntimeException("int failed");
        if (prefs.getLong("long") != Long.MAX_VALUE)
            throw new GdxRuntimeException("long failed");
        if (prefs.getFloat("float") != 1.2345f)
            throw new GdxRuntimeException("float failed");
        if (!prefs.getString("string").equals("test!"))
            throw new GdxRuntimeException("string failed");
    }
    prefs.clear();
    prefs.putBoolean("bool", true);
    prefs.putInteger("int", 1234);
    prefs.putLong("long", Long.MAX_VALUE);
    prefs.putFloat("float", 1.2345f);
    prefs.putString("string", "test!");
    prefs.flush();
    if (prefs.getBoolean("bool") != true)
        throw new GdxRuntimeException("bool failed");
    if (prefs.getInteger("int") != 1234)
        throw new GdxRuntimeException("int failed");
    if (prefs.getLong("long") != Long.MAX_VALUE)
        throw new GdxRuntimeException("long failed");
    if (prefs.getFloat("float") != 1.2345f)
        throw new GdxRuntimeException("float failed");
    if (!prefs.getString("string").equals("test!"))
        throw new GdxRuntimeException("string failed");
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Preferences(com.badlogic.gdx.Preferences)

Example 20 with Preferences

use of com.badlogic.gdx.Preferences in project AnotherMonekyParadox by SantiagoMille.

the class PantallaJuego4 method show.

@Override
public void show() {
    crearCamara();
    crearMapa();
    // personaje = new Personaje(astroCaminata0, astroCaminata1, astroCaminata2, astroCaminata3);
    fondo1 = new Fondo(fondoNivel01);
    fondo2 = new Fondo(fondoNivel02);
    fondo2.getImagenA().setPosition(fondo1.getImagenA().getWidth(), 0);
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    difficulty = prefs.getFloat("Difficulty");
    batch = new SpriteBatch();
    // Lista Enemigos
    listaEnemigos = new Array<Enemigo>();
    for (int i = 0; i < 10; i++) {
        enemigo = new Enemigo(alien01Frame0, alien01Frame1, alien01Frame2, alien01Frame3, true, i);
        listaEnemigos.add(enemigo);
    }
    for (int i = 0; i < 10; i++) {
        enemigo = new Enemigo(alien01Frame0, alien01Frame1, alien01Frame2, alien01Frame3, false, i);
        listaEnemigos.add(enemigo);
    }
    // Lista Balas
    listaBalas = new Array<Bala>();
    listaBalasBoss = new Array<Bala>();
    // Lista Granadas
    listaGranadas = new Array<Granada>();
    estado = PantallaJuego.EstadoJuego.JUGANDO;
    Gdx.input.setCatchBackKey(true);
    musicNivel4.setLooping(true);
    if (prefs.getBoolean("music", true)) {
        musicNivel4.play();
    }
// Gdx.input.setInputProcessor(new ProcesadorEntrada());
}
Also used : Enemigo(mx.itesm.another_monkey_paradox.Objetos.Enemigo) Bala(mx.itesm.another_monkey_paradox.Objetos.Bala) Granada(mx.itesm.another_monkey_paradox.Objetos.Granada) Preferences(com.badlogic.gdx.Preferences) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Fondo(mx.itesm.another_monkey_paradox.Utils.Fondo)

Aggregations

Preferences (com.badlogic.gdx.Preferences)23 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)7 Texture (com.badlogic.gdx.graphics.Texture)5 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)5 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)5 Bala (mx.itesm.another_monkey_paradox.Objetos.Bala)5 Enemigo (mx.itesm.another_monkey_paradox.Objetos.Enemigo)5 Granada (mx.itesm.another_monkey_paradox.Objetos.Granada)5 Fondo (mx.itesm.another_monkey_paradox.Utils.Fondo)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 Stage (com.badlogic.gdx.scenes.scene2d.Stage)4 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)4 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)4 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)4 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)4 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2