Search in sources :

Example 31 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.

the class PantallaJuego method crearMapa.

private void crearMapa() {
    cargarTexturas();
    stageNivel = new Stage(vista);
    // para sacar número random donde se crean los powerups
    random = new Random();
    // Objeto que dibuja texto
    // font = new BitmapFont(Gdx.files.internal("tutorial.fnt"));
    // textoGly = new GlyphLayout(font,"Score");
    // textoGlyGran = new GlyphLayout(font,"Score");
    boss = new Texture("boss_stand.png");
    itemBosss = new Texture("item_boss.png");
    bossSprite = new Sprite(boss);
    bossSprite.setPosition(ANCHO, ALTO);
    itemBoss = new Sprite(itemBosss);
    itemBoss.setPosition(ANCHO * 3 / 4, ALTO / 4);
    for (int i = 0; i < 5; i++) {
        if (i < cuentaVidas) {
            vidas.add(new PowerUp(new Texture("vida.png"), camara.position.x + 10 - ANCHO / 2 + (75 * i), ALTO - 70, true));
        } else {
            vidas.add(new PowerUp(new Texture("vida.png"), camara.position.x + 10 - ANCHO / 2 + (75 * i), ALTO - 70, false));
        }
    }
    // Granadas Colisión
    // banana1 = new Bala(bananaDisparo,false);
    banana1.set(-100, -100);
    // banana2 = new Bala(bananaDisparo, false);
    banana2.set(-100, -100);
    // banana3 = new Bala(bananaDisparo, false);
    banana3.set(-100, -100);
    // banana4 = new Bala(bananaDisparo, true);
    banana4.set(-100, -100);
    // banana5 = new Bala(bananaDisparo, true);
    banana5.set(-100, -100);
    // banana6 = new Bala(bananaDisparo, true);
    banana6.set(-100, -100);
    randomX = random.nextDouble() * 4000;
    randomX2 = random.nextDouble() * 4000;
    // Barra Bala
    Bar.setPosition(745, ALTO * 0.93f);
    barraBala.setPosition(740, (ALTO * 0.92f) + 3);
    bananaBarra.setPosition(700, (ALTO * 0.90f));
    granada.setPosition(ANCHO * 3 / 4 - granada.getWidth() / 2 + 25, ALTO / 4 - granada.getHeight() / 2 - 80);
    granadasNum.setPosition(ANCHO * 0.712f - granadasNum.getWidth() / 2, ALTO / 4 - granadasNum.getHeight() / 2 - 40);
    /*
        //boton disparo
        TextureRegionDrawable btnArma = new TextureRegionDrawable(new TextureRegion(botonDisparo));
        TextureRegionDrawable btnArmaPressed = new TextureRegionDrawable(new TextureRegion(botonDisparoPressed));
        arma = new ImageButton(btnArma, btnArmaPressed);
        */
    arma.setPosition(ANCHO * 3 / 4 - arma.getWidth() / 2 + arma.getWidth() + 55, ALTO / 4 - arma.getHeight() / 2 - 80);
    /*
        //boton pausa
        TextureRegionDrawable btnPausa = new TextureRegionDrawable(new TextureRegion(botonPausa));
        pausa = new ImageButton(btnPausa);
        */
    pausa.setSize(55, 55);
    pausa.setPosition(ANCHO / 2 - pausa.getWidth() / 2, 680 - pausa.getHeight() / 2);
    /*
        //boton continua
        TextureRegionDrawable btnContinua = new TextureRegionDrawable(new TextureRegion(botonContinua));
        continua = new ImageButton(btnContinua);
        */
    continua.setSize(55, 55);
    continua.setPosition(ANCHO / 2 - continua.getWidth() / 2, 680 - continua.getHeight() / 2);
    /*
        //boton Home
        TextureRegionDrawable btnHome = new TextureRegionDrawable(new TextureRegion(botonHome));
        home = new ImageButton(btnContinua);
        */
    home.setSize(55, 55);
    home.setPosition(ANCHO / 2 - continua.getWidth() / 2, 680 - continua.getHeight() / 2);
    // Texturas para el pad
    Skin skin = new Skin();
    skin.add("fondo", padBack);
    skin.add("boton", padKnob);
    Touchpad.TouchpadStyle estilo = new Touchpad.TouchpadStyle();
    estilo.background = skin.getDrawable("fondo");
    estilo.knob = skin.getDrawable("boton");
    // Crea el pad
    // Radio, estilo
    Touchpad pad = new Touchpad(64, estilo);
    // x,y - ancho,alto
    pad.setBounds(40, 30, 200, 200);
    // Comportamiento del pad
    pad.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            Touchpad pad = (Touchpad) actor;
            if (pad.getKnobPercentX() > 0.25) {
                // Más de 20% de desplazamiento DERECHA
                personaje.setRight(true);
                isMovingRight = true;
                isMovingLeft = false;
            } else if (pad.getKnobPercentX() < -0.25) {
                // Más de 20% IZQUIERDA
                personaje.setRight(false);
                isMovingLeft = true;
                isMovingRight = false;
            } else {
                isMovingLeft = false;
                isMovingRight = false;
            }
        }
    });
    // Transparente
    pad.setColor(1, 1, 1, 0.7f);
    // Comportamiento de Boton Granada
    granada.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            if (maxGrandas > 0) {
                if (!isFliped) {
                    Granada grana = new Granada(bananaGranada, false);
                    grana.set(personaje.getX() + 105, personaje.getY() + 68);
                    listaGranadas.add(grana);
                    maxGrandas--;
                } else {
                    Granada grana = new Granada(bananaGranada, true);
                    grana.set(personaje.getX(), personaje.getY() + 68);
                    listaGranadas.add(grana);
                    maxGrandas--;
                }
            }
        }
    });
    // Comportamiento de Boton Disparo
    arma.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            if (Bar.getValue() > 0.1) {
                if (music) {
                    gunSound.play();
                }
                if (!isFliped) {
                    Bala nueva = new Bala(bananaDisparo, false);
                    nueva.set(personaje.getX() + 105, personaje.getY() + 68);
                    listaBalas.add(nueva);
                } else {
                    if (music) {
                        gunSound.play();
                    }
                    Bala nueva = new Bala(bananaDisparo, true);
                    nueva.set(personaje.getX(), personaje.getY() + 68);
                    listaBalas.add(nueva);
                }
            }
            Bar.setValue(Bar.getValue() - 0.25f);
        }
    });
    // Comportamiento de Boton Pausa
    pausa.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            estado = EstadoJuego.PAUSADO;
            // main.setScreen((Screen) new EscenaPausa(vista,batch));
            if (escenaPausa == null) {
                escenaPausa = new EscenaPausa(vista);
            }
            Gdx.input.setInputProcessor(escenaPausa);
            // dispose();
            pause();
        }
    });
    stageNivel.addActor(granada);
    stageNivel.addActor(arma);
    stageNivel.addActor(pausa);
    stageNivel.addActor(pad);
    stageNivel.addActor(Bar);
    Gdx.input.setInputProcessor(stageNivel);
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Granada(mx.itesm.another_monkey_paradox.Objetos.Granada) Bala(mx.itesm.another_monkey_paradox.Objetos.Bala) Texture(com.badlogic.gdx.graphics.Texture) Random(java.util.Random) Touchpad(com.badlogic.gdx.scenes.scene2d.ui.Touchpad) Actor(com.badlogic.gdx.scenes.scene2d.Actor) PowerUp(mx.itesm.another_monkey_paradox.Objetos.PowerUp) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 32 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.

the class PantallaJuego2 method crearMapa.

private void crearMapa() {
    cargarTexturas();
    Gdx.input.setCatchBackKey(true);
    stageNivel = new Stage(vista);
    // para sacar número random donde se crean los powerups
    random = new Random();
    // Objeto que dibuja texto
    // font = new BitmapFont(Gdx.files.internal("tutorial.fnt"));
    // textoGly = new GlyphLayout(font,"Score");
    // textoGlyGran = new GlyphLayout(font,"Score");
    boss = new Texture("Bosses/jefe_n2.png");
    itemBosss = new Texture("Bosses/item_boss2.png");
    bossSprite = new Sprite(boss);
    bossSprite.setPosition(ANCHO, ALTO);
    itemBoss = new Sprite(itemBosss);
    itemBoss.setPosition(ANCHO * 3 / 4, ALTO / 4);
    for (int i = 0; i < 5; i++) {
        if (i < cuentaVidas) {
            vidas.add(new PowerUp(new Texture("vida.png"), camara.position.x + 10 - ANCHO / 2 + (75 * i), ALTO - 70, true));
        } else {
            vidas.add(new PowerUp(new Texture("vida.png"), camara.position.x + 10 - ANCHO / 2 + (75 * i), ALTO - 70, false));
        }
    }
    // Granadas Colisión
    // banana1 = new Bala(bananaDisparo,false);
    banana1.set(-100, -100);
    // banana2 = new Bala(bananaDisparo, false);
    banana2.set(-100, -100);
    // banana3 = new Bala(bananaDisparo, false);
    banana3.set(-100, -100);
    // banana4 = new Bala(bananaDisparo, true);
    banana4.set(-100, -100);
    // banana5 = new Bala(bananaDisparo, true);
    banana5.set(-100, -100);
    // banana6 = new Bala(bananaDisparo, true);
    banana6.set(-100, -100);
    randomX = random.nextDouble() * 4000;
    randomX2 = random.nextDouble() * 4000;
    Bar.setPosition(745, ALTO * 0.93f);
    barraBala.setPosition(740, (ALTO * 0.92f) + 3);
    bananaBarra.setPosition(700, (ALTO * 0.90f));
    granada.setPosition(ANCHO * 3 / 4 - granada.getWidth() / 2 + 25, ALTO / 4 - granada.getHeight() / 2 - 80);
    granadasNum.setPosition(ANCHO * 0.712f - granadasNum.getWidth() / 2, ALTO / 4 - granadasNum.getHeight() / 2 - 40);
    /*
        //boton disparo
        TextureRegionDrawable btnArma = new TextureRegionDrawable(new TextureRegion(botonDisparo));
        TextureRegionDrawable btnArmaPressed = new TextureRegionDrawable(new TextureRegion(botonDisparoPressed));
        arma = new ImageButton(btnArma, btnArmaPressed);
        */
    arma.setPosition(ANCHO * 3 / 4 - arma.getWidth() / 2 + arma.getWidth() + 55, ALTO / 4 - arma.getHeight() / 2 - 80);
    /*
        //boton pausa
        TextureRegionDrawable btnPausa = new TextureRegionDrawable(new TextureRegion(botonPausa));
        pausa = new ImageButton(btnPausa);
        */
    pausa.setSize(55, 55);
    pausa.setPosition(ANCHO / 2 - pausa.getWidth() / 2, 680 - pausa.getHeight() / 2);
    /*
        //boton continua
        TextureRegionDrawable btnContinua = new TextureRegionDrawable(new TextureRegion(botonContinua));
        continua = new ImageButton(btnContinua);
        */
    continua.setSize(55, 55);
    continua.setPosition(ANCHO / 2 - continua.getWidth() / 2, 680 - continua.getHeight() / 2);
    /*
        //boton Home
        TextureRegionDrawable btnHome = new TextureRegionDrawable(new TextureRegion(botonHome));
        home = new ImageButton(btnContinua);
        */
    home.setSize(55, 55);
    home.setPosition(ANCHO / 2 - continua.getWidth() / 2, 680 - continua.getHeight() / 2);
    // Texturas para el pad
    Skin skin = new Skin();
    skin.add("fondo", padBack);
    skin.add("boton", padKnob);
    Touchpad.TouchpadStyle estilo = new Touchpad.TouchpadStyle();
    estilo.background = skin.getDrawable("fondo");
    estilo.knob = skin.getDrawable("boton");
    // Crea el pad
    // Radio, estilo
    Touchpad pad = new Touchpad(64, estilo);
    // x,y - ancho,alto
    pad.setBounds(40, 30, 200, 200);
    // Comportamiento del pad
    pad.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            Touchpad pad = (Touchpad) actor;
            if (pad.getKnobPercentX() > 0.25) {
                // Más de 20% de desplazamiento DERECHA
                personaje.setRight(true);
                isMovingRight = true;
                isMovingLeft = false;
            } else if (pad.getKnobPercentX() < -0.25) {
                // Más de 20% IZQUIERDA
                personaje.setRight(false);
                isMovingLeft = true;
                isMovingRight = false;
            } else {
                isMovingLeft = false;
                isMovingRight = false;
            }
        }
    });
    // Transparente
    pad.setColor(1, 1, 1, 0.7f);
    // Comportamiento de Boton Granada
    granada.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            if (maxGrandas > 0) {
                if (!isFliped) {
                    Granada grana = new Granada(bananaGranada, false);
                    grana.set(personaje.getX() + 105, personaje.getY() + 68);
                    listaGranadas.add(grana);
                    maxGrandas--;
                } else {
                    Granada grana = new Granada(bananaGranada, true);
                    grana.set(personaje.getX(), personaje.getY() + 68);
                    listaGranadas.add(grana);
                    maxGrandas--;
                }
            }
        }
    });
    // Comportamiento de Boton Disparo
    arma.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            if (Bar.getValue() > 0.1) {
                if (music) {
                    gunSound.play();
                }
                if (!isFliped) {
                    Bala nueva = new Bala(bananaDisparo, false);
                    nueva.set(personaje.getX() + 105, personaje.getY() + 68);
                    listaBalas.add(nueva);
                } else {
                    if (music) {
                        gunSound.play();
                    }
                    Bala nueva = new Bala(bananaDisparo, true);
                    nueva.set(personaje.getX(), personaje.getY() + 68);
                    listaBalas.add(nueva);
                }
            }
            Bar.setValue(Bar.getValue() - 0.25f);
        }
    });
    // Comportamiento de Boton Pausa
    pausa.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            estado = PantallaJuego.EstadoJuego.PAUSADO;
            // main.setScreen((Screen) new EscenaPausa2(vista,batch));
            if (escenaPausa == null) {
                escenaPausa = new PantallaJuego2.EscenaPausa2(vista, batch);
            }
            Gdx.input.setInputProcessor(escenaPausa);
            pause();
        }
    });
    stageNivel.addActor(granada);
    stageNivel.addActor(arma);
    stageNivel.addActor(pausa);
    stageNivel.addActor(pad);
    stageNivel.addActor(Bar);
    Gdx.input.setInputProcessor(stageNivel);
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Granada(mx.itesm.another_monkey_paradox.Objetos.Granada) Bala(mx.itesm.another_monkey_paradox.Objetos.Bala) Texture(com.badlogic.gdx.graphics.Texture) Random(java.util.Random) Touchpad(com.badlogic.gdx.scenes.scene2d.ui.Touchpad) Actor(com.badlogic.gdx.scenes.scene2d.Actor) PowerUp(mx.itesm.another_monkey_paradox.Objetos.PowerUp) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 33 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.

the class PantallaCredits method crearMenu.

private void crearMenu() {
    stageMenu = new Stage(vista);
    boolAdr = false;
    boolFer = false;
    boolBri = false;
    boolDie = false;
    boolSan = false;
    title = new Texto(1, 1, 1);
    Adrian = new Texto(1, 1, 1);
    Santi = new Texto(1, 1, 1);
    Fer = new Texto(1, 1, 1);
    Brian = new Texto(1, 1, 1);
    Diego = new Texto(1, 1, 1);
    Itesm = new Texto(1, 1, 1);
    imgBackground = new Texture("space.png");
    adrian = new Texture("pp_a.PNG");
    santi = new Texture("pp_s.PNG");
    fernando = new Texture("pp.PNG");
    diego = new Texture("pp_d.PNG");
    brian = new Texture("pp_b.PNG");
    logoTec = new Texture("logoTec.png");
    spriteBackground = new Sprite(imgBackground);
    tec = new Sprite(logoTec);
    tec.setPosition(ANCHO * 0.85f - 40, 95);
    TextureRegionDrawable trdSan = new TextureRegionDrawable(new TextureRegion(santi));
    san = new ImageButton(trdSan);
    san.setPosition(0, ALTO - 280 + 48);
    san.addAction(Actions.alpha(0));
    san.addAction(Actions.moveTo(800, ALTO - 280 + 48, 0.8f));
    san.addAction(Actions.fadeIn(0.8f));
    san.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            boolSan = true;
        }
    });
    TextureRegionDrawable trdBri = new TextureRegionDrawable(new TextureRegion(brian));
    bri = new ImageButton(trdBri);
    bri.setPosition(0, ALTO - 400 + 48);
    bri.addAction(Actions.alpha(0));
    bri.addAction(Actions.moveTo(800, ALTO - 400 + 48, 0.8f));
    bri.addAction(Actions.fadeIn(0.8f));
    bri.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            boolBri = true;
        }
    });
    TextureRegionDrawable trdFer = new TextureRegionDrawable(new TextureRegion(fernando));
    fer = new ImageButton(trdFer);
    fer.setPosition(0, ALTO - 520 + 48);
    fer.addAction(Actions.alpha(0));
    fer.addAction(Actions.moveTo(800, ALTO - 520 + 48, 0.8f));
    fer.addAction(Actions.fadeIn(0.8f));
    fer.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            boolFer = true;
        }
    });
    TextureRegionDrawable trdAdr = new TextureRegionDrawable(new TextureRegion(adrian));
    adr = new ImageButton(trdAdr);
    adr.setPosition(0, ALTO - 640 + 48);
    adr.addAction(Actions.alpha(0));
    adr.addAction(Actions.moveTo(800, ALTO - 640 + 48, 0.8f));
    adr.addAction(Actions.fadeIn(0.8f));
    adr.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            boolAdr = true;
        }
    });
    TextureRegionDrawable trdDie = new TextureRegionDrawable(new TextureRegion(diego));
    die = new ImageButton(trdDie);
    die.setPosition(0, ALTO - 760 + 48);
    die.addAction(Actions.alpha(0));
    die.addAction(Actions.moveTo(800, ALTO - 760 + 48, 0.8f));
    die.addAction(Actions.fadeIn(0.8f));
    die.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            boolDie = true;
        }
    });
    // Boton Return
    TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
    ImageButton btnReturn = new ImageButton(trdReturn);
    btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
    btnReturn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // Gdx.app.log("ClickListener","Si se clickeoooo");
            main.setScreen(new PantallaDeveloper(main));
        }
    });
    // Fotos
    foto.setScaling(Scaling.fit);
    stageMenu.addActor(btnReturn);
    stageMenu.addActor(san);
    stageMenu.addActor(bri);
    stageMenu.addActor(fer);
    stageMenu.addActor(adr);
    stageMenu.addActor(die);
    Gdx.input.setInputProcessor(stageMenu);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) Texture(com.badlogic.gdx.graphics.Texture) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 34 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.

the class PantallaDeveloper method crearMenu.

private void crearMenu() {
    stageMenu = new Stage(vista);
    prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    musicOn = prefs.getBoolean("music", true);
    dif = prefs.getFloat("Difficulty");
    sen = prefs.getFloat("Sensitivity");
    Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
    imgBackground = new Texture("pantalla_config2.png");
    spriteBackground = new Sprite(imgBackground);
    spriteBackground.setAlpha(0.55f);
    // Boton Return
    TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
    ImageButton btnReturn = new ImageButton(trdReturn);
    btnReturn.setPosition(20, ALTO - 30 - btnReturn.getHeight());
    // Click en boton Return
    btnReturn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            difficulty = sliderDif.getPercent();
            sensitivity = sliderSens.getPercent();
            prefs.putFloat("Difficulty", difficulty);
            prefs.putFloat("Sensitivity", sensitivity);
            prefs.flush();
            main.setScreen(new PantallaMenu(main));
        }
    });
    // Boton Play
    trdMusicPressed = new TextureRegionDrawable(new TextureRegion(new Texture("mute.png")));
    trdMusic = new TextureRegionDrawable(new TextureRegion(new Texture("audio.png")));
    btnPlay = new ImageButton(trdMusic);
    btnPlayPressed = new ImageButton(trdMusicPressed);
    if (musicOn) {
        btnPlayPressed.setVisible(false);
        btnPlay.setVisible(true);
    } else {
        btnPlayPressed.setVisible(true);
        btnPlay.setVisible(false);
    }
    btnPlay.setSize(100, 100);
    btnPlayPressed.setSize(100, 100);
    btnPlay.setPosition(ANCHO - btnPlay.getWidth() - 30, ALTO - btnPlay.getHeight() - 20);
    btnPlayPressed.setPosition(ANCHO - btnPlay.getWidth() - 30, ALTO - btnPlay.getHeight() - 20);
    // Click en boton Play
    btnPlay.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            musicOn = false;
            prefs.putBoolean("music", false);
            prefs.flush();
            btnPlayPressed.setVisible(true);
            btnPlay.setVisible(false);
        }
    });
    // Click en boton Play
    btnPlayPressed.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            musicOn = true;
            prefs.putBoolean("music", true);
            prefs.flush();
            btnPlayPressed.setVisible(false);
            btnPlay.setVisible(true);
        }
    });
    titulo = new Texto(1, 1, 1);
    Texture diff = new Texture("button_difficulty.png");
    diffi = new Sprite(diff);
    diffi.setPosition(ANCHO / 2 - 110 - diffi.getWidth(), ALTO / 2);
    sliderDif = new Slider(0, 100, 1, false, skin);
    sliderDif.setValue(dif * 100);
    sliderDif.setPosition(diffi.getX() + 100, ALTO / 3);
    sliderDif.setScale(2);
    Texture sens = new Texture("button_sensitivity.png");
    sensi = new Sprite(sens);
    sensi.setPosition(ANCHO / 2 + 110, ALTO / 2);
    sliderSens = new Slider(0, 100, 1, false, skin);
    sliderSens.setValue(sen * 100);
    sliderSens.setPosition(sensi.getX() + 100, ALTO / 3);
    sliderSens.setScale(2);
    TextureRegionDrawable creditsTRD = new TextureRegionDrawable(new TextureRegion(new Texture("button_credits.png")));
    ImageButton btnCreds = new ImageButton(creditsTRD);
    btnCreds.setPosition(ANCHO - 20 - btnCreds.getWidth(), 20);
    btnCreds.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            difficulty = sliderDif.getPercent();
            sensitivity = sliderSens.getPercent();
            prefs.putFloat("Difficulty", difficulty);
            prefs.putFloat("Sensitivity", sensitivity);
            prefs.flush();
            main.setScreen(new PantallaCredits(main));
        }
    });
    stageMenu.addActor(btnCreds);
    stageMenu.addActor(btnPlay);
    stageMenu.addActor(btnPlayPressed);
    stageMenu.addActor(sliderDif);
    stageMenu.addActor(sliderSens);
    stageMenu.addActor(btnReturn);
    Gdx.input.setInputProcessor(stageMenu);
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Slider(com.badlogic.gdx.scenes.scene2d.ui.Slider) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texture(com.badlogic.gdx.graphics.Texture) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 35 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project AnotherMonekyParadox by SantiagoMille.

the class PantallaEasterEgg method crearElementos.

public void crearElementos() {
    stage = new Stage(vista);
    imgBackground = new Texture("EasterEgg/EGG.png");
    background = new Sprite(imgBackground);
    background.setPosition(0, 0);
    // Boton Return
    TextureRegionDrawable trdBack = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
    ImageButton back = new ImageButton(trdBack);
    back.setPosition(30, ALTO - 30 - back.getHeight());
    back.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaMenu(main));
        }
    });
    stage.addActor(back);
    Gdx.input.setInputProcessor(stage);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Texture(com.badlogic.gdx.graphics.Texture) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)74 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)72 Stage (com.badlogic.gdx.scenes.scene2d.Stage)39 Texture (com.badlogic.gdx.graphics.Texture)26 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)26 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)24 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)23 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)23 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)23 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)22 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)21 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)18 Actor (com.badlogic.gdx.scenes.scene2d.Actor)17 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)12 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)7 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)7 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)6 Touchpad (com.badlogic.gdx.scenes.scene2d.ui.Touchpad)6 Texto (mx.itesm.another_monkey_paradox.Utils.Texto)6 Random (java.util.Random)5