Search in sources :

Example 56 with ClickListener

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

the class PantallaJuegoSurvival 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();
    for (int i = 0; i < 5; i++) {
        if (i < 3) {
            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, 210, 210);
    // 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.1f);
        }
    });
    // 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 PantallaJuegoSurvival.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 : 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 57 with ClickListener

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

the class EscenaAstroGanador method crearBoton.

private void crearBoton() {
    // Boton Home
    assetManager.load("boton Home.png", Texture.class);
    assetManager.finishLoading();
    imgBoton = assetManager.get("boton Home.png");
    stageNivel = new Stage(vista);
    texto1 = new Texto(1, 1, 1);
    texto2 = new Texto(1, 1, 1);
    TextureRegionDrawable btnHome = new TextureRegionDrawable(new TextureRegion(imgBoton));
    home = new ImageButton(btnHome);
    home.setSize(155, 155);
    home.setPosition(ANCHO * 2 / 10, ALTO / 2);
    home.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaSplash(main));
        }
    });
    // Boton Next
    assetManager.load("PlayButton.png", Texture.class);
    assetManager.finishLoading();
    imgBN = assetManager.get("PlayButton.png");
    TextureRegionDrawable btnNext = new TextureRegionDrawable(new TextureRegion(imgBN));
    next = new ImageButton(btnNext);
    next.setSize(155, 155);
    next.setPosition(ANCHO * 7 / 10, ALTO / 2);
    next.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            if (nivel == 2) {
                main.setScreen(new PantallaCinematica(main, "Cinematicas/C N1.png", 2, score, vidas, granadas));
            } else if (nivel == 3) {
                main.setScreen(new PantallaCinematica(main, "Cinematicas/C N2.png", 3, score, vidas, granadas));
            } else if (nivel == 4) {
                main.setScreen(new PantallaCinematica(main, "Cinematicas/C N3W.png", 4, score, vidas, granadas));
            } else if (nivel == 44) {
                main.setScreen(new PantallaCinematica(main, "Cinematicas/C N4.png", 44, score, vidas, granadas));
            }
        }
    });
    stageNivel.addActor(home);
    stageNivel.addActor(next);
    Gdx.input.setInputProcessor(stageNivel);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) PantallaSplash(mx.itesm.another_monkey_paradox.PantallasDeCarga.PantallaSplash) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 58 with ClickListener

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

the class EscenaAstroMuerto method crearBoton.

private void crearBoton() {
    assetManager.load("regresar.png", Texture.class);
    assetManager.load("HistoriaAstro/right-arrow_w.png", Texture.class);
    assetManager.finishLoading();
    imgBoton = assetManager.get("regresar.png");
    imgBotonHome = assetManager.get("HistoriaAstro/right-arrow_w.png");
    stageNivel = new Stage(vista);
    texto = new Texto(1, 1, 1);
    TextureRegionDrawable btnHome = new TextureRegionDrawable(new TextureRegion(imgBoton));
    home = new ImageButton(btnHome);
    if (!isThirdLevel) {
        home.setPosition(ANCHO / 2 - imgBoton.getWidth() / 2, -100);
        home.addAction(Actions.moveTo(ANCHO / 2 - imgBoton.getWidth() / 2, ALTO / 5 - imgBoton.getHeight() / 2, 0.6f));
    } else {
        home.setPosition(-500, -100);
    }
    home.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaSplash(main));
        }
    });
    TextureRegionDrawable btnRregresar = new TextureRegionDrawable((new TextureRegion(imgBotonHome)));
    regresar = new ImageButton(btnRregresar);
    if (isThirdLevel) {
        regresar.setPosition(ANCHO - 103, ALTO - 25 - regresar.getHeight());
    } else {
        regresar.setPosition(-500, ALTO - 30 - regresar.getHeight());
    }
    regresar.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaCargandoStoryMode(main, 1, 0, 3, 5));
        }
    });
    stageNivel.addActor(home);
    stageNivel.addActor(regresar);
    Gdx.input.setInputProcessor(stageNivel);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) PantallaCargandoStoryMode(mx.itesm.another_monkey_paradox.PantallasDeCarga.PantallaCargandoStoryMode) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) PantallaSplash(mx.itesm.another_monkey_paradox.PantallasDeCarga.PantallaSplash) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 59 with ClickListener

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

the class PantallaCinematica method crearMenu.

private void crearMenu() {
    stageMenu = new Stage(vista);
    imgBackground = new Texture(this.background);
    spriteBackground = new Sprite(imgBackground);
    // Boton Next
    TextureRegionDrawable trdNext = new TextureRegionDrawable(new TextureRegion(new Texture("HistoriaAstro/right-arrow_w.png")));
    ImageButton btnNext = new ImageButton(trdNext);
    btnNext.setPosition(ANCHO - 100, ALTO - 30 - btnNext.getHeight());
    btnNext.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 (nivel == 2) {
                main.setScreen(new PantallaCargandoStoryMode(main, 2, score, vidas, granadas));
            } else if (nivel == 3) {
                main.setScreen(new PantallaCargandoStoryMode(main, 3, score, vidas, granadas));
            } else if (nivel == 4) {
                main.setScreen(new PantallaCargandoStoryMode(main, 4, score, vidas, granadas));
            } else if (nivel == 44) {
                main.setScreen(new PantallaSplash(main));
            }
        }
    });
    stageMenu.addActor(btnNext);
    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) PantallaCargandoStoryMode(mx.itesm.another_monkey_paradox.PantallasDeCarga.PantallaCargandoStoryMode) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) PantallaSplash(mx.itesm.another_monkey_paradox.PantallasDeCarga.PantallaSplash) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Texture(com.badlogic.gdx.graphics.Texture) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 60 with ClickListener

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

the class PantallaHistoriaAstro method crearElementos.

public void crearElementos() {
    stage = new Stage(vista);
    imgBackground = new Texture("HistoriaAstro/C 1.png");
    background = new Sprite(imgBackground);
    background.setPosition(0, 0);
    // Boton Return
    TextureRegionDrawable trdNext = new TextureRegionDrawable(new TextureRegion(new Texture("HistoriaAstro/right-arrow.png")));
    next = new ImageButton(trdNext);
    TextureRegionDrawable trdNextW = new TextureRegionDrawable(new TextureRegion(new Texture("HistoriaAstro/right-arrow_w.png")));
    nextW = new ImageButton(trdNextW);
    TextureRegionDrawable trdSkip = new TextureRegionDrawable(new TextureRegion(new Texture("HistoriaAstro/skip.png")));
    skip = new ImageButton(trdSkip);
    xnext = ANCHO - 100;
    ynext = ALTO - 30 - next.getHeight();
    nextW.setPosition(xnext, ynext);
    next.setPosition(xnext, ynext + 500);
    skip.setPosition(xnext - 12, 100);
    skip.setSize(80, 80);
    nextW.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            count++;
            if (count == 1) {
                imgBackground = new Texture("HistoriaAstro/C 2.png");
                background = new Sprite(imgBackground);
                background.setPosition(0, 0);
                skip.setPosition(-100, -100);
            } else if (count == 2) {
                imgBackground = new Texture("HistoriaAstro/C 3.png");
                background = new Sprite(imgBackground);
                background.setPosition(0, 0);
                next.setPosition(xnext, ynext);
                nextW.setPosition(xnext, ynext + 500);
            }
        }
    });
    skip.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaCargandoStoryMode(main, 1, 0, 3, 5));
        }
    });
    next.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaCargandoStoryMode(main, 1, 0, 3, 5));
        }
    });
    stage.addActor(next);
    stage.addActor(nextW);
    stage.addActor(skip);
    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) PantallaCargandoStoryMode(mx.itesm.another_monkey_paradox.PantallasDeCarga.PantallaCargandoStoryMode) 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)82 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)74 Stage (com.badlogic.gdx.scenes.scene2d.Stage)39 Texture (com.badlogic.gdx.graphics.Texture)27 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)27 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)24 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)24 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)23 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)23 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)22 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)21 Actor (com.badlogic.gdx.scenes.scene2d.Actor)18 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)18 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)17 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)7 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)6 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)6 Touchpad (com.badlogic.gdx.scenes.scene2d.ui.Touchpad)6 Texto (mx.itesm.another_monkey_paradox.Utils.Texto)6 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)5