Search in sources :

Example 6 with ClickListener

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

the class PantallaScoresStory method crearMenu.

@Override
void crearMenu() {
    super.stageMenu = new Stage(vista);
    title = new Texto(1, 1, 1);
    imgBackground = new Texture("logros.png");
    spriteBackground = new Sprite(imgBackground);
    spriteBackground.setPosition(0, 0);
    // spriteBackground.setAlpha(0.7f);
    Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    String names = prefs.getString("names", null);
    if (names == null) {
        // prefs.putString("names", "Astro");
        names = "Astro,";
    }
    String scores = prefs.getString("highscores", null);
    if (scores == null) {
        // prefs.putString("highscores", "10000");
        scores = "10000,";
    }
    Table table = new Table(skin);
    table.defaults().pad(10f);
    table.setFillParent(true);
    table.setPosition(table.getX(), table.getY() + 250);
    /**
     * Se hace el titulo de scores
     */
    // Label scoresTitle = new Label("HIGHSCORES STORY MODE", skin);
    // scoresTitle.setFontScale(4f,4f);
    // scoresTitle.setAlignment(Align.center);
    /**
     * Se crean las columnas con puntuajes
     */
    Label columnName;
    Label columnScore;
    String[] allScores = scores.split(",");
    String[] allNames = names.split(",");
    int i = 0;
    // table.add(scoresTitle).colspan(2).fillX().height(150);
    table.row();
    for (String name : allNames) {
        columnName = new Label(name + ": ", skin);
        columnName.setFontScale(3f, 3f);
        table.add(columnName);
        columnScore = new Label(allScores[i], skin);
        columnScore.setFontScale(3f, 3f);
        table.add(columnScore);
        i++;
        table.row();
    }
    // 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());
    // Click en boton Return
    btnReturn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaMenu(main));
        }
    });
    stageMenu.addActor(table);
    stageMenu.addActor(btnReturn);
    Gdx.input.setInputProcessor(stageMenu);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) 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) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Preferences(com.badlogic.gdx.Preferences) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 7 with ClickListener

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

the class PantallaTutorial method crearMainView.

private void crearMainView() {
    stageMenu = new Stage(vista);
    imgBackground = new Texture("pantall_tutorial.png");
    spriteBackground = new Sprite(imgBackground);
    spriteBackground.setPosition(0, 0);
    // spriteBackground.setAlpha(0.7f);
    // 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());
    // Click en boton Return
    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 PantallaMenu(main));
        }
    });
    stageMenu.addActor(btnReturn);
    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) Texture(com.badlogic.gdx.graphics.Texture) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 8 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project gdx-skineditor by cobolfoo.

the class WidgetsBar method initializeButtons.

/**
 */
public void initializeButtons() {
    group = new ButtonGroup();
    Tooltips.TooltipStyle styleTooltip = new Tooltips.TooltipStyle(game.skin.getFont("default-font"), game.skin.getDrawable("default-round"), game.skin.getColor("white"));
    String[] widgets = SkinEditorGame.widgets;
    for (String widget : widgets) {
        ImageButtonStyle style = new ImageButtonStyle();
        style.checked = game.skin.getDrawable("default-round-down");
        style.down = game.skin.getDrawable("default-round-down");
        style.up = game.skin.getDrawable("default-round");
        style.imageUp = game.skin.getDrawable("widgets/" + widget);
        ImageButton button = new ImageButton(style);
        button.setUserObject(widget);
        Tooltips tooltip = new Tooltips(styleTooltip, getStage());
        tooltip.registerTooltip(button, (String) button.getUserObject());
        button.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                game.screenMain.panePreview.refresh();
                game.screenMain.paneOptions.refresh();
            }
        });
        group.add(button);
        add(button).pad(5);
    }
}
Also used : ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) ButtonGroup(com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup) Tooltips(com.mobidevelop.maps.editor.ui.utils.Tooltips) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 9 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.

the class DefaultSceneScreen method setUI.

@Override
public void setUI(final UI ui) {
    this.ui = ui;
    recorder = ui.getRecorder();
    testerBot = ui.getTesterBot();
    pie = new PieMenu(this);
    textManagerUI = new TextManagerUI(ui.getSkin());
    menuButton = new Button(ui.getSkin(), "menu");
    dialogUI = new DialogUI(ui);
    pointer = new ScenePointer(ui.getSkin());
    inventoryUI = new InventoryUI(this, pointer);
    inventoryButton = new InventoryButton(ui.getSkin(), inventoryUI);
    uiMode = UIModes.valueOf(Config.getProperty(Config.UI_MODE, "TWO_BUTTONS").toUpperCase(Locale.ENGLISH));
    if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen) && uiMode == UIModes.TWO_BUTTONS) {
        uiMode = UIModes.PIE;
    }
    pie.setVisible(false);
    menuButton.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            ui.setCurrentScreen(Screens.MENU_SCREEN);
        }
    });
    retrieveAssets(ui.getUIAtlas());
    stage = new Stage(viewport);
    stage.addActor(textManagerUI);
    stage.addActor(dialogUI);
    stage.addActor(inventoryButton);
    stage.addActor(menuButton);
    stage.addActor(inventoryUI);
    stage.addActor(pie);
}
Also used : TextManagerUI(com.bladecoder.engine.ui.TextManagerUI) Button(com.badlogic.gdx.scenes.scene2d.ui.Button) InventoryButton(com.bladecoder.engine.ui.InventoryButton) DialogUI(com.bladecoder.engine.ui.DialogUI) PieMenu(com.bladecoder.engine.ui.PieMenu) InventoryUI(com.bladecoder.engine.ui.InventoryUI) Stage(com.badlogic.gdx.scenes.scene2d.Stage) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) InventoryButton(com.bladecoder.engine.ui.InventoryButton) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 10 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.

the class VerbUI method createInventoryPanel.

private Table createInventoryPanel() {
    Table inventory = new Table();
    inventory.defaults().pad(MARGIN);
    for (int i = 0; i < INVENTORY_COLS * INVENTORY_ROWS; i++) {
        if (i % INVENTORY_COLS == 0)
            inventory.row();
        ImageButton.ImageButtonStyle s = new ImageButton.ImageButtonStyle(style.inventoryButtonStyle);
        RendererDrawable r = new RendererDrawable();
        s.imageUp = r;
        ImageButton b = new ImageButton(s);
        inventory.add(b).fill().expand();
        b.setUserObject(i);
        inventorySlots.add(b);
        b.addListener(new ClickListener() {

            public void clicked(InputEvent event, float x, float y) {
                int i = (Integer) event.getListenerActor().getUserObject();
                Inventory inv = World.getInstance().getInventory();
                target = null;
                if (i < inv.getNumItems()) {
                    InteractiveActor actor = inv.get(i);
                    if (currentVerb.equals("use") || currentVerb.equals("give")) {
                        target = actor;
                    } else {
                        sceneScreen.runVerb(actor, currentVerb, null);
                    }
                }
            }
        });
        b.getImageCell().pad(MARGIN).expand().fill();
    }
    return inventory;
}
Also used : ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) Inventory(com.bladecoder.engine.model.Inventory)

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