Search in sources :

Example 66 with ClickListener

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

the class PantallaSurvival method crearMenu.

private void crearMenu() {
    stageMenu = new Stage(vista);
    imgBackground = new Texture("Background.png");
    spriteBackground = new Sprite(imgBackground);
    spriteBackground.setPosition(0, 0);
    imgLogo = new Texture("LOGO-2.png");
    spriteLogo = new Sprite(imgLogo);
    spriteLogo.setPosition(ANCHO / 2 - spriteLogo.getWidth() / 2, ALTO - spriteLogo.getHeight() - 50);
    // Boton Play
    TextureRegionDrawable trdPlay = new TextureRegionDrawable(new TextureRegion(new Texture("button_start.png")));
    TextureRegionDrawable trdPlayPressed = new TextureRegionDrawable(new TextureRegion(new Texture("button_start_pressed.png")));
    ImageButton btnPlay = new ImageButton(trdPlay, trdPlayPressed);
    btnPlay.setPosition(ANCHO / 2 - btnPlay.getWidth() / 2, ALTO / 4 - btnPlay.getHeight() / 2);
    // Boton Leaderboard
    TextureRegionDrawable trdLead = new TextureRegionDrawable(new TextureRegion(new Texture("but-lead.png")));
    TextureRegionDrawable trdLeadPush = new TextureRegionDrawable(new TextureRegion(new Texture("but-lead-push.png")));
    ImageButton btnLead = new ImageButton(trdLead, trdLeadPush);
    btnLead.setPosition(ANCHO / 4 - btnLead.getWidth() / 2, ALTO / 4 - btnLead.getHeight() / 2);
    // Boton Config
    TextureRegionDrawable trdConfig = new TextureRegionDrawable(new TextureRegion(new Texture("but-config.png")));
    TextureRegionDrawable trdConfigPush = new TextureRegionDrawable(new TextureRegion(new Texture("but-config-push.png")));
    ImageButton btnConfig = new ImageButton(trdConfig, trdConfigPush);
    btnConfig.setPosition(ANCHO * 3 / 4 - btnConfig.getWidth() / 2, ALTO / 4 - btnConfig.getHeight() / 2);
    // Boton Tutorial
    TextureRegionDrawable trdTut = new TextureRegionDrawable(new TextureRegion(new Texture("but-tut.png")));
    TextureRegionDrawable trdTutPush = new TextureRegionDrawable(new TextureRegion(new Texture("but-tut-push.png")));
    ImageButton btnTut = new ImageButton(trdTut, trdTutPush);
    btnTut.setPosition(ANCHO * 9 / 10 - btnTut.getWidth() / 2, ALTO * 9 / 10 - btnTut.getHeight() / 2);
    // Click en boton Play
    btnPlay.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");
            dispose();
            main.setScreen(new PantallaJuego(main));
        }
    });
    // Click en boton Lead
    btnLead.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");
            dispose();
            main.setScreen(new PantallaScoresStory(main));
        }
    });
    // Click en boton Tutorial
    btnTut.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");
            dispose();
            main.setScreen(new PantallaTutorialStoryMode(main));
        }
    });
    // Click en boton Config
    btnConfig.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");
            dispose();
            main.setScreen(new PantallaDeveloper(main));
        }
    });
    stageMenu.addActor(btnPlay);
    stageMenu.addActor(btnLead);
    stageMenu.addActor(btnConfig);
    stageMenu.addActor(btnTut);
    Gdx.input.setInputProcessor(stageMenu);
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Stage(com.badlogic.gdx.scenes.scene2d.Stage) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 67 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project var3dframe by Var3D.

the class StageTest method init.

@Override
public void init() {
    // 设置背景
    setBackground(R.image.bg);
    // 设置标题
    txt_logo = game.getLabel(R.strings.logo).setColor(Color.BLUE).setStroke(Color.CYAN).setPosition(getWidth() / 2, getHeight() - 20, Align.top).setAlpha(0.9f).touchOff().show();
    // Tost
    btn_tost = game.getButton(R.image.pause_btn_bg).setPosition(0, 380).addClicAction().show();
    btn_tost.add(game.getLabel(R.strings.tost).getActor());
    btn_tost.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            game.setUserData(DialogMessge.MODEL, new DialogMessge.Model("这是一个Tost范例"));
            game.showDialog(DialogMessge.class);
        }
    });
    // 自定义对话框
    btn_dialog = game.getButton(R.image.pause_btn_bg).setPosition(0, 320).addClicAction().show();
    btn_dialog.add(game.getLabel(R.strings.dialogTitle).getActor());
    btn_dialog.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            game.showDialog(DialogTest.class);
        }
    });
    // shader测试
    WaterActor waterActor = game.getUI(new WaterActor(game.getTextureRegion(R.image.badlogic))).show(Align.center);
    OutLineActor outLineActor = game.getUI(new OutLineActor(game.getTextureRegion(R.image.tank_4))).setPosition(getWidth() / 2, waterActor.getY() - 10, Align.top).show();
}
Also used : DialogMessge(var3d.net.center.DialogMessge) WaterActor(var3d.net.center.shaderActor.WaterActor) OutLineActor(var3d.net.center.shaderActor.OutLineActor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 68 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Entitas-Java by Rubentxu.

the class GuiFactory method createPadButtons.

public Table createPadButtons(float width, float height, InputEntity player) {
    Table tableControlPad = new Table();
    PlayerInputController stateController = player.getPlayerInputController();
    tableControlPad.row().height(height);
    ImageButton btnLeft = new ImageButton(skin, "buttonLeft");
    tableControlPad.add(btnLeft).width(width).expandY().fill();
    btnLeft.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchDown(event, x, y, pointer, button);
            // controller.leftPressed();
            // controller.rightReleased();
            player.replacePlayerInputController(true, false, stateController.jumpPressed);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchUp(event, x, y, pointer, button);
            // controller.leftReleased();
            player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            System.out.println("Event- " + event.getType());
            super.touchDragged(event, x, y, pointer);
            if (isOver(event.getListenerActor(), x, y)) {
                // controller.rightReleased();
                // controller.leftPressed();
                player.replacePlayerInputController(true, false, stateController.jumpPressed);
            } else {
                // controller.leftReleased();
                player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
            }
        }
    });
    ImageButton btnRight = new ImageButton(skin, "buttonRight");
    tableControlPad.add(btnRight).width(width).expandY().fill().padRight((width) * 2);
    btnRight.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchDown(event, x, y, pointer, button);
            // controller.leftReleased();
            // controller.rightPressed();
            player.replacePlayerInputController(false, true, stateController.jumpPressed);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchUp(event, x, y, pointer, button);
            // controller.rightReleased();
            player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            System.out.println("Event- " + event.getType());
            super.touchDragged(event, x, y, pointer);
            if (isOver(event.getListenerActor(), x, y)) {
                // controller.rightPressed();
                // controller.leftReleased();
                player.replacePlayerInputController(false, true, stateController.jumpPressed);
            } else {
                // controller.rightReleased();
                player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
            }
        }
    });
    ImageButton btnUP = new ImageButton(skin, "buttonUp");
    tableControlPad.add(btnUP).width(width).expandY().fill();
    btnUP.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchDown(event, x, y, pointer, button);
            // controller.jumpPressed();
            player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchUp(event, x, y, pointer, button);
            // controller.jumpReleased();
            player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            System.out.println("Event- " + event.getType());
            super.touchDragged(event, x, y, pointer);
            if (isOver(event.getListenerActor(), x, y)) {
                // controller.jumpPressed();
                player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
            } else {
                // controller.jumpReleased();
                player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
            }
        }
    });
    tableControlPad.setBounds(0, 0, Gdx.graphics.getWidth(), height + 10);
    return tableControlPad;
}
Also used : PlayerInputController(com.ilargia.games.states.game.component.input.PlayerInputController) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 69 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Entitas-Java by Rubentxu.

the class GuiFactory method createPadButtons.

public Table createPadButtons(float width, float height, InputEntity player) {
    Table tableControlPad = new Table();
    PlayerInputController stateController = player.getPlayerInputController();
    tableControlPad.row().height(height);
    ImageButton btnLeft = new ImageButton(skin, "buttonLeft");
    tableControlPad.add(btnLeft).width(width).expandY().fill();
    btnLeft.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchDown(event, x, y, pointer, button);
            // controller.leftPressed();
            // controller.rightReleased();
            player.replacePlayerInputController(true, false, stateController.jumpPressed);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchUp(event, x, y, pointer, button);
            // controller.leftReleased();
            player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            System.out.println("Event- " + event.getType());
            super.touchDragged(event, x, y, pointer);
            if (isOver(event.getListenerActor(), x, y)) {
                // controller.rightReleased();
                // controller.leftPressed();
                player.replacePlayerInputController(true, false, stateController.jumpPressed);
            } else {
                // controller.leftReleased();
                player.replacePlayerInputController(false, stateController.rightPressed, stateController.jumpPressed);
            }
        }
    });
    ImageButton btnRight = new ImageButton(skin, "buttonRight");
    tableControlPad.add(btnRight).width(width).expandY().fill().padRight((width) * 2);
    btnRight.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchDown(event, x, y, pointer, button);
            // controller.leftReleased();
            // controller.rightPressed();
            player.replacePlayerInputController(false, true, stateController.jumpPressed);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchUp(event, x, y, pointer, button);
            // controller.rightReleased();
            player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            System.out.println("Event- " + event.getType());
            super.touchDragged(event, x, y, pointer);
            if (isOver(event.getListenerActor(), x, y)) {
                // controller.rightPressed();
                // controller.leftReleased();
                player.replacePlayerInputController(false, true, stateController.jumpPressed);
            } else {
                // controller.rightReleased();
                player.replacePlayerInputController(stateController.leftPressed, false, stateController.jumpPressed);
            }
        }
    });
    ImageButton btnUP = new ImageButton(skin, "buttonUp");
    tableControlPad.add(btnUP).width(width).expandY().fill();
    btnUP.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchDown(event, x, y, pointer, button);
            // controller.jumpPressed();
            player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("Event " + event.getType());
            super.touchUp(event, x, y, pointer, button);
            // controller.jumpReleased();
            player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            System.out.println("Event- " + event.getType());
            super.touchDragged(event, x, y, pointer);
            if (isOver(event.getListenerActor(), x, y)) {
                // controller.jumpPressed();
                player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, true);
            } else {
                // controller.jumpReleased();
                player.replacePlayerInputController(stateController.leftPressed, stateController.rightPressed, false);
            }
        }
    });
    tableControlPad.setBounds(0, 0, Gdx.graphics.getWidth(), height + 10);
    return tableControlPad;
}
Also used : PlayerInputController(com.indignado.games.states.game.component.input.PlayerInputController) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 70 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Eidolons by IDemiurge.

the class ActionValueContainer method init.

@Override
protected void init(TextureRegion texture, String name, String value) {
    super.init(texture, name, value);
    clickAction = () -> {
    };
    addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            clickAction.run();
        }
    });
}
Also used : InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener)

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