Java 类com.badlogic.gdx.scenes.scene2d.ui.ImageButton 实例源码

项目:enklave    文件:ScreenCombat.java   
private void drawdefenders(){
    defenders = new DrawDefenders();
    groupBtnDefender = new Group();
    Button btn1 = new Button(new ImageButton.ImageButtonStyle());
    btn1.setName("btn1");
    btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn1.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn1);
    Button btn2 = new Button(new ImageButton.ImageButtonStyle());
    btn2.setName("btn2");
    btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn2.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f);
    groupBtnDefender.addActor(btn2);
    Button btn3 = new Button(new ImageButton.ImageButtonStyle());
    btn3.setName("btn3");
    btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn3.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn3);
}
项目:enklave    文件:ScreenCombat.java   
private void drawAttachers(){
    attachers = new DrawAttachers();
    Button btn1 = new Button(new ImageButton.ImageButtonStyle());
    btn1.setName("btn4");
    btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn1.setPosition(Gdx.graphics.getWidth() - btn1.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn1);
    Button btn2 = new Button(new ImageButton.ImageButtonStyle());
    btn2.setName("btn5");
    btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn2.setPosition(Gdx.graphics.getWidth() - btn2.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f);
    groupBtnDefender.addActor(btn2);
    Button btn3 = new Button(new ImageButton.ImageButtonStyle());
    btn3.setName("btn6");
    btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f);
    btn3.setPosition(Gdx.graphics.getWidth() - btn3.getWidth() * 1.13f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f);
    groupBtnDefender.addActor(btn3);
}
项目:Polymorph    文件:DeathScreen.java   
public void initButtons(int score,TextureAtlas buttonAtlas) {
    Skin buttonSkin = new Skin();
    buttonSkin.addRegions(buttonAtlas);

    //TODO FIX THIS SHIT INDENTATION
    //TODO Long-term fix the magic numbers
    ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"),
                                                                    buttonSkin.getDrawable("playbutton"));
    playButton.setSize(256, 64);
    playButton.setPosition(screenSize.width/2-playButton.getWidth()/2,
                           screenSize.height/2-playButton.getHeight()/2+50);
    playButton.addListener(new InputListener() {

        @Override
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
            polymorph.setScreen(new GameScreen(polymorph));
            DeathScreenMusic.stop();
            return true;
        }
    });

    stage.addActor(playButton);

}
项目:Hexpert    文件:ObjectiveDialog.java   
public void setObjectives(Objective[] objectives, boolean[] objectiveStatus)
{
    this.objectives = objectives;
    this.objectiveStatus = objectiveStatus;

    if(objectives.length != objectiveStatus.length)
        throw new IllegalArgumentException();

    getContentTable().clearChildren();
    getBackground().setMinHeight(200 + 100 * objectives.length);
    getContentTable().setDebug(false);
    for(int i = 0; i < objectives.length; i++)
    {
        ImageButton imgCheck = new ImageButton(new TextureRegionDrawable(
                new TextureRegion((Texture)
                        hexpert.assetManager.get(objectiveStatus[i] ? TEXTURE_CORRECT : TEXTURE_BAD
                ))));

        Label labelObjective = new Label(objectives[i].toString(hexpert.i18NBundle), getSkin());

        getContentTable().add(imgCheck).width(100).height(80);
        imgCheck.getImageCell().expand().fill();
        getContentTable().add(labelObjective);
        getContentTable().row();
    }
}
项目:le-pendu    文件:MenuScreen.java   
public MenuScreen(final LePendu game) {
    super(game);

    titleImg = new Image(new TextureRegionDrawable(game.atlas.findRegion("title")));
    playBtn  = new ImageButton(new TextureRegionDrawable(game.atlas.findRegion("playBtn")));
    decosImg = new Image(new TextureRegionDrawable(game.atlas.findRegion("decos")));

    table.add(titleImg).top().padTop(169);
    table.row();
    table.add(playBtn).expandY();
    table.row();
    table.add(decosImg).bottom().padBottom(50);

    playBtn.addListener(new ChangeListener() {
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            game.setScreen(new DifficultyScreen(game));
        }
    });
}
项目:le-pendu    文件:KeyboardActor.java   
public KeyboardActor(final PlayScreen playScreen) {
    alphabet = new Texture("alphabet.png");

    for (int i = 0 ; i < 26 ; i++) {
        if (i%7 == 0) {
            hg  = new HorizontalGroup();
            this.addActor(hg);
        }
        final char character = (char) (i + 65);

        button = new ImageButton(new TextureRegionDrawable(new TextureRegion(alphabet, i * 90, 0, 90, 90)));
        button.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                playScreen.proposeLetter(character);
            }
        });

        hg.addActor(button);
    }
}
项目:OmiClub    文件:GraphicsLoader.java   
public static Map<String, ImageButton> getButtons(){
    if(!buttonMap.isEmpty()){
        return buttonMap;
    }
    buttonMap.put("singleBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Single_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Single_P"))));
    buttonMap.put("hostBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Host_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Host_P"))));
    buttonMap.put("joinBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Join_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Join_P"))));
    buttonMap.put("exitBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Exit_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Exit_P"))));
    buttonMap.put("aboutBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("About_N")),
            new SpriteDrawable(buttonAtlas.createSprite("About_P"))));
    buttonMap.put("settingsBtn", new ImageButton(
            new SpriteDrawable(buttonAtlas.createSprite("Sett_N")),
            new SpriteDrawable(buttonAtlas.createSprite("Sett_P"))));

    return buttonMap;
}
项目:Teleport-Ball    文件:HelpButton.java   
public HelpButton(final Application app, final MenuHud menuHud, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("help-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("help-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked (InputEvent event, float x, float y)
        {
            menuHud.removeAllActorsFromStage();
            ColorOverlay.enabled = false;
            app.setScreen(new HelpScreen(app, atlas));
        }
    });
}
项目:Teleport-Ball    文件:PlayButton.java   
public PlayButton(final Application app, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("pb-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("pb-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);
    button.addListener(new ClickListener()
    {
        @Override
        public void clicked (InputEvent event, float x, float y)
        {
            app.setScreen(new GameScreen(app, atlas));
        }
    });
}
项目:Teleport-Ball    文件:HomeButton.java   
public HomeButton(final Application app, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("home-up"));
    drawableDown = new SpriteDrawable(atlas.createSprite("home-down"));

    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            Ball.died = false;
            GameScreen.adAlreadyShowed++;
            app.setScreen(new MenuScreen(app));
        }
    });
}
项目:Teleport-Ball    文件:RestartButton.java   
public RestartButton(final Player player, final Ball ball, final TextureAtlas atlas)
{
    drawableUp = new SpriteDrawable(atlas.createSprite("rb-normal"));
    drawableDown = new SpriteDrawable(atlas.createSprite("rb-down"));
    applyFilter();

    button = new ImageButton(drawableUp, drawableDown);

    button.addListener(new ClickListener()
    {
        @Override
        public void clicked(InputEvent event, float x, float y)
        {
            Ball.died = false;
            GameScreen.adAlreadyShowed++;
            ball.reset();
            player.reset();
        }
    });
}
项目:Inspiration    文件:ButtonUI.java   
public ButtonUI(){
        super(Assets.instance.STATUSUI_SKIN);
        //buttons
        inventoryButton= new ImageButton(Assets.instance.STATUSUI_SKIN, "inventory-button");
        inventoryButton.getImageCell().size(32, 32);

        questButton = new ImageButton(Assets.instance.STATUSUI_SKIN, "quest-button");
        questButton.getImageCell().size(32,32);

        //Add to layout
        defaults().expand().fill();

        //UI
        Table topTable = new Table();
        topTable.add(questButton);
        topTable.add(inventoryButton);
        topTable.row();

        this.add(topTable);

//        this.debug();
        this.pack();
    }
项目:cocos-ui-libgdx    文件:CCButtonTest.java   
@Test
@NeedGL
public void shouldParseSingleButtonWithImages() throws Exception {
    FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf");

    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("single-button/MainScene.json"), null, null, defaultFont, null);

    Group group = editor.createGroup();
    Actor actor = group.findActor("Button_1");

    assertThat(actor, not(nullValue()));
    assertThat(actor, instanceOf(ImageButton.class));
    ImageButton imageButton = (ImageButton) actor;
    assertThat(imageButton.getScaleX(), is(1.7958f));
    assertThat(imageButton.getScaleY(), is(1.8041f));
    ImageButton.ImageButtonStyle style = imageButton.getStyle();
    assertThat(style.imageDisabled, instanceOf(NinePatchDrawable.class));
    assertThat(style.up, instanceOf(NinePatchDrawable.class));
    assertThat(style.down, instanceOf(NinePatchDrawable.class));
}
项目:TerraLegion    文件:ItemBox.java   
public ItemBox(ItemStack stack, int inventoryX, int inventoryY, String extra) {
    this.stack = stack;
    this.inventoryX = inventoryX;
    this.inventoryY = inventoryY;
    this.extra = extra;

    btnGroup = CachePool.getGroup();
    btnGroup.setBounds(0, 0, 60, 60);

    style = new ImageButton.ImageButtonStyle();
    style.up = inventoryBoxDrawable;
    btn = new ImageButton(style);
    btn.setBounds(0, 0, 60, 60);
    btn.setName(extra);
    btnGroup.addActor(btn);

    setupBox();
    add(btnGroup);
}
项目:ChessGDX    文件:SliderMenuTable.java   
/**
 * A menu containing a settings button, exit button, and a button to expand
 * ("slide") the side panel.
 * 
 * @param skin
 */
SliderMenuTable(Skin skin) {

    int screenWidth = Gdx.graphics.getWidth();
    int screenHeight = Gdx.graphics.getHeight();

    mSliderButton = new ImageButton(skin, MenuSkin.IB_SLIDER);
    mSettingsButton = new ImageButton(skin, MenuSkin.IB_SETTINGS);
    mExitButton = new ImageButton(skin, MenuSkin.IB_EXIT);

    add(mSliderButton).size(screenHeight / 20, screenHeight / 20);
    row().fill();
    add(mSettingsButton).size(screenHeight / 20, screenHeight / 20);
    row().fill();
    add(mExitButton).size(screenHeight / 20, screenHeight / 20);

    pack();

    setPosition(screenWidth - getWidth(), 0);
}
项目:GdxDemo3D    文件:GameSpeedController.java   
public GameSpeedController(TextureAtlas buttonAtlas) {
    btnPauseStyle = new ImageButton.ImageButtonStyle();
    btnPauseStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("pause-up"));
    btnPauseStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("pause-down"));

    btnPlayStyle = new ImageButton.ImageButtonStyle();
    btnPlayStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("play-up"));
    btnPlayStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("play-down"));

    btnSlowStyle = new ImageButton.ImageButtonStyle();
    btnSlowStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("slow-up"));
    btnSlowStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("slow-down"));

    imageButton = new ImageButton(btnPauseStyle);

    add(imageButton);

    imageButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            setGameSpeed();
            event.cancel();
        }
    });
}
项目:GDXJam    文件:FormationPatternTable.java   
public FormationPatternTable (final Entity squad, Skin skin) {
    this.skin = skin;
    buttonGroup = new ButtonGroup<ImageButton>();
    buttonGroup.setMaxCheckCount(1);
    buttonGroup.setMinCheckCount(1);

    for(int i = 0; i < FormationPatternType.values().length; i++){
        final ImageButton button = createFormationButton(FormationPatternType.values()[i], skin);
        button.addListener(new ChangeListener() {

            @Override
            public void changed (ChangeEvent event, Actor actor) {
                if(button.isChecked()){
                    Components.SQUAD.get(squad).setFormationPattern((FormationPatternType) button.getUserObject());
                }

            }
        });

        add(button);
        buttonGroup.add(button);
    }
}
项目:GDXJam    文件:FormationPatternTable.java   
private ImageButton createFormationButton(FormationPatternType pattern, Skin skin){
        ImageButtonStyle style = new ImageButtonStyle(skin.get("default", ButtonStyle.class));

        Sprite sprite = new Sprite(Assets.ui.formationIcons.get(pattern.ordinal()));
        sprite.setSize(26, 26);
        sprite.setColor(Color.BLUE);
        SpriteDrawable drawable = new SpriteDrawable(sprite);

        style.imageUp = drawable;
//      style.imageDown = drawable.tint(Color.CYAN);
        style.imageChecked = drawable.tint(Color.RED);

        ImageButton button = new ImageButton(style);
        button.setUserObject(pattern);
        return button;
    }
项目:Terminkalender    文件:GamesOpenActor.java   
public GamesOpenActor(Skin skin) {
    super(skin);

    games = new GamesOpen();
    gamesWindow = new ScrollWindow("Spiele", skin, games.getGamesTable());
    ImageButton backButton = new ImageButton(skin, "imageButtonBack");

    setFillParent(true);

    add(gamesWindow).width(800).height(TeacherMain.HEIGHT - 16).expand().left().pad(8);
    add(backButton).width(135).height(125).getTable().pad(16);

    backButton.addListener(new ChangeListener() {
        public void changed (ChangeEvent event, Actor actor) {
            AppMain.setNewScreen(AppMain.loginScreen);
        }
    });
}
项目:Terminkalender    文件:TeacherGamesScreen.java   
public TeacherGamesScreen(Viewport viewport, SpriteBatch batch) {
    super(viewport, batch);

    TextureRegion backgroundTexture = new TextureRegion(Resources.assets.get("background.png", Texture.class));
    Skin skin = Resources.skin;

    background = new Background(backgroundTexture);
    gamesActor = new GamesActor(skin);
    changeToLoginRegisterButton = new ImageButton(skin, "imageButtonBack");
    reconnectButton = Resources.reconnectButton;

    stage.addActor(background);
    stage.addActor(gamesActor);
    stage.addActor(changeToLoginRegisterButton);

    changeToLoginRegisterButton.setBounds(AppMain.WIDTH - 102, AppMain.HEIGHT - 102, 100, 100);

    changeToLoginRegisterButton.addListener(new ClickListener() {

        @Override 
        public void clicked(InputEvent event, float x, float y){
            TeacherMain.setNewScreen(TeacherMain.teacherLoginRegisterScreen);
        }
    });
}
项目:master-maze    文件:ControllerButton.java   
/**
 * Button for the controller overlay.
 * @param key The key that it will trigger.
 * @param flipX Flip image horizontally.
 * @param flipY Flip image vertically.
 * @param rotate Rotate 90 degrees.
 */
public ControllerButton(int key, boolean flipX, boolean flipY, boolean rotate) {
    this.key = key;
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    TextureRegion t = Assets.getGameTexture("controller_button");
    t.flip(flipX, flipY);
    // Rotate 90 degrees (u1 = u1, v1 = v2, u2 = u2, v2 = v1)
    if(rotate) {
        float v2 = t.getV2();
        float v1 = t.getV();
        t.setV(v2);
        t.setV2(v1);
    }

    style.imageUp = new TextureRegionDrawable(t);

    this.button = new ImageButton(style);
    this.button.addListener(new ControllerButtonListener(this));
}
项目:droidtowers    文件:ToolMenu.java   
private ClickListener makePurchaseButtonClickListener(final String dialogTitle, final GridObjectTypeFactory typeFactory) {
    return new VibrateClickListener() {
        public void onClick(InputEvent event, float x, float y) {
            close();

            if (purchaseDialog == null) {
                if (typeFactory instanceof RoomTypeFactory) {
                    TutorialEngine.instance().moveToStepWhenReady("tutorial-unlock-lobby");
                }

                makePurchaseDialog(dialogTitle, typeFactory, ((ImageButton) event.getListenerActor()).getStyle());
            } else {
                purchaseDialog.dismiss();
                purchaseDialog = null;
            }
        }
    };
}
项目:droidtowers    文件:ToolMenu.java   
private void makePurchaseDialog(String title, GridObjectTypeFactory typeFactory, final ImageButton.ImageButtonStyle purchaseButtonStyle) {
    purchaseDialog = new GridObjectPurchaseMenu(getStage(), title, typeFactory, new Runnable() {
        public void run() {
            hudToolButton.resetStyle();
        }
    });

    purchaseDialog.setDismissCallback(new Runnable() {
        public void run() {
            Gdx.app.log(TAG, "Tool: " + InputSystem.instance().getCurrentTool());
            purchaseDialog = null;
            if (InputSystem.instance().getCurrentTool() instanceof PickerTool) {
                hudToolButton.resetStyle();
            } else {
                hudToolButton.setStyle(purchaseButtonStyle);
            }
        }
    }).show();

}
项目:HAW-SE2-projecthorse    文件:Puzzle.java   
/**
 * erstelle ein Zurückbutton. um zurück zur Bilderauswahl gelangen zu können
 * rufe die Methode addListener(...) auf, füge den Button in die zweite
 * Stage
 */
private void createButtons() {
    ImageButton buttonBack = new ImageButton(new TextureRegionDrawable(
            AssetManager.getTextureRegion("ui", "backIcon")));

    buttonBack.setHeight(95);
    buttonBack.setWidth(95);

    buttonBack.setPosition(PuzzleManager.getMyXPos()
            + getPuzzleManager().getMyWidth() - buttonBack.getWidth(),
            PuzzleManager.getMyYPos() + getPuzzleManager().getMyHeight());

    addListener(buttonBack);

    PuzzleManager.addToStage(PuzzleManager.getSecondstage(), buttonBack);

}
项目:HAW-SE2-projecthorse    文件:NavbarStableButton.java   
/**
 * Konstruktor.
 */
public NavbarStableButton() {
    ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.HOME);

    this.addActor(imageButton);
    this.addListener(new InputListener() {

        @Override
        public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer,
                final int button) {
            Gdx.app.log("Settings Button", "Settings BUTTON CLick");

            GameManagerFactory.getInstance().navigateToLevel("playerMenu");

            return true;
        };

    });
    this.setWidth(imageButton.getHeight());
}
项目:HAW-SE2-projecthorse    文件:NavbarCityInfoButton.java   
/**
 * Konstruktor.
 */
public NavbarCityInfoButton() {
    ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.INFO);

    this.addActor(imageButton);
    this.addListener(new InputListener() {

        @Override
        public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer,
                final int button) {
            clicked();

            return true;
        };

    });
    this.setWidth(imageButton.getHeight());
}
项目:HAW-SE2-projecthorse    文件:NavbarSettingsButton.java   
/**
 * Konstruktor.
 */
public NavbarSettingsButton() {
    ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.SETTINGS);

    this.addActor(imageButton);
    this.addListener(new InputListener() {

        @Override
        public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer,
                final int button) {
            getNavigationBar().getOverlay().showPopup(new SettingsPopup());
            Gdx.app.log("Settings Button", "Settings BUTTON CLick");

            return true;
        };

    });
    this.setWidth(imageButton.getHeight());
}
项目:HAW-SE2-projecthorse    文件:NavbarLootGalleryButton.java   
/**
 * Konstruktor.
 */
public NavbarLootGalleryButton() {
    ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.LOOT);

    this.addActor(imageButton);
    this.addListener(new InputListener() {

        @Override
        public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer,
                final int button) {

            GameManager gm = GameManagerFactory.getInstance();
            if (gm.getCurrentLevelID() != "lootGallery") {
                gm.navigateToLevel("lootGallery");
            }

            return true;
        };

    });
    this.setWidth(imageButton.getHeight());
}
项目:HAW-SE2-projecthorse    文件:NavbarPauseButton.java   
/**
 * Konstruktor.
 */
public NavbarPauseButton() {
    ImageButton imageButton = new ButtonSmall(ButtonSmall.ButtonType.PAUSE);
    this.setWidth(imageButton.getHeight());
    this.addActor(imageButton);
    this.addListener(new InputListener() {

        @Override
        public boolean touchDown(final InputEvent event, final float x, final float y, final int pointer,
                final int button) {
            Gdx.app.log("PAUSE Button", "PAUSE BUTTON CLick");
            NavBar navBar = NavbarPauseButton.this.getNavigationBar();

            Popup p = new GamePausePopup();
            Overlay overlay = navBar.getOverlay();
            overlay.getLevel().pause();
            overlay.showPopup(p);

            return true;
        };

    });
}
项目:tafl    文件:TaflGame.java   
public Button createSwitchScreenButton(
        Sprite text,
        Sprite up,
        Sprite down,
        final AbstractScreen<TaflGame> parent,
        final AbstractScreen<TaflGame> screen) {

    ImageButton button = new ImageButton(new DoubleTextureDrawable(new TextureRegion(up), new TextureRegion(text)),
            new DoubleTextureDrawable(new TextureRegion(down), new TextureRegion(text)));

    button.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            soundService.playSound(Assets.Sounds.CLICK_SOUND);
            parent.switchScreen(screen);
        }
    });

    return button;
}
项目:tafl    文件:InstructionScreen.java   
private void initControls() {
    TextureRegion textureRegion = new TextureRegion(
            game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.CLOSE));

    TextureRegionDrawable imageUp = new TextureRegionDrawable(textureRegion);
    imageUp.setMinWidth(game.deviceSettings.menuButtonHeight / 2);
    imageUp.setMinHeight(game.deviceSettings.menuButtonHeight / 2);

    closeButton = new ImageButton(imageUp);
    closeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.soundService.playSound(Assets.Sounds.CLICK_SOUND);
            back();
        }
    });

    Table controls = new Table();
    controls.setFillParent(true);
    controls.add(closeButton).expand().bottom().right().pad(
            game.deviceSettings.menuSpacing).size(game.deviceSettings.menuButtonHeight);
    stage.addActor(controls);
}
项目:tafl    文件:AboutScreen.java   
private void initControls() {
    TextureRegion textureRegion = new TextureRegion(
            game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.CLOSE));

    TextureRegionDrawable imageUp = new TextureRegionDrawable(textureRegion);
    imageUp.setMinWidth(game.deviceSettings.menuButtonHeight / 2);
    imageUp.setMinHeight(game.deviceSettings.menuButtonHeight / 2);

    ImageButton closeButton = new ImageButton(imageUp);
    closeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.soundService.playSound(Assets.Sounds.CLICK_SOUND);
            back();
        }
    });

    Table controls = new Table();
    controls.setFillParent(true);
    controls.add(closeButton).expand().bottom().right().pad(
            game.deviceSettings.menuSpacing).size(game.deviceSettings.menuButtonHeight);
    stage.addActor(controls);
}
项目:tafl    文件:HudFactory.java   
private static void createUndo(HudRenderingComponent component,
        Skin skin, Table table, TaflWorld gameWorld) {

    final World world = gameWorld.world;

    TextureRegion textureRegion = new TextureRegion(
            gameWorld.game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.UNDO));
    Drawable imageUp = new TextureRegionDrawable(textureRegion);
    ImageButton button = new ImageButton(imageUp);

    button.addListener(new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            UndoEvent undoEvent = SystemEvent.createEvent(UndoEvent.class);
            world.postEvent(null, undoEvent);
        }
    });
    table.add(button).size(gameWorld.game.deviceSettings.hudButtonHeight).expandX();
}
项目:tafl    文件:HudFactory.java   
private static void createHint(HudRenderingComponent component,
        Skin skin, Table table, TaflWorld gameWorld) {

    final World world = gameWorld.world;

    TextureRegion textureRegion = new TextureRegion(
            gameWorld.game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.HINT));
    Drawable imageUp = new TextureRegionDrawable(textureRegion);
    ImageButton button = new ImageButton(imageUp);

    button.addListener(new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            HintEvent undoEvent = SystemEvent.createEvent(HintEvent.class);
            world.postEvent(null, undoEvent);
        }
    });
    table.add(button).size(gameWorld.game.deviceSettings.hudButtonHeight).expandX();
}
项目:tafl    文件:HudFactory.java   
private static void createMenu(HudRenderingComponent component,
        Skin skin, Table table, final TaflWorld gameWorld) {

    final World world = gameWorld.world;

    TextureRegion textureRegion = new TextureRegion(
            gameWorld.game.graphicsService.getSprite(
                    Assets.GraphicFiles.ATLAS_PIECES, Assets.Icons.MENU));
    Drawable imageUp = new TextureRegionDrawable(textureRegion);
    ImageButton button = new ImageButton(imageUp);

    button.addListener(new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            LifeCycleEvent lifecycleEvent = SystemEvent.createEvent(LifeCycleEvent.class);
            lifecycleEvent.lifecycle = LifeCycle.MENU;
            world.postEvent(null, lifecycleEvent);
        }
    });
    table.add(button).size(gameWorld.game.deviceSettings.hudButtonHeight).expandX();
}
项目:gaiasky    文件:DesktopMusicActors.java   
@Override
   public Actor[] getActors(Skin skin) {
ImageButton musicTooltip = new OwnImageButton(skin, "tooltip");
musicTooltip.addListener(new TextTooltip(
    I18n.bundle.format("gui.tooltip.music", SysUtilsFactory.getSysUtils().getDefaultMusicDir()), skin));

ImageButton reloadMusic = new OwnImageButton(skin, "reload");
reloadMusic.setName("reload music");
reloadMusic.addListener(new EventListener() {
    @Override
    public boolean handle(Event event) {
    if (event instanceof ChangeEvent) {
        EventManager.instance.post(Events.MUSIC_RELOAD_CMD);
        return true;
    }
    return false;
    }
});
reloadMusic.addListener(new TextTooltip(I18n.bundle.get("gui.music.reload"), skin));

return new Actor[] { musicTooltip, reloadMusic };
   }
项目:bladecoder-adventure-engine    文件:ProjectToolbar.java   
private void addToolBarButton(Skin skin, ImageButton button, String icon, String text, String tooltip) {
    ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
    TextureRegion image = Ctx.assetManager.getIcon(icon);
    style.imageUp = new TextureRegionDrawable(image);

    try {
        TextureRegion imageDisabled = Ctx.assetManager.getIcon(icon + "_disabled");

        if(imageDisabled != null)
            style.imageDisabled = new TextureRegionDrawable(imageDisabled);
    } catch (Exception e) {

    }

    button.setStyle(style);
    // button.row();
    // button.add(new Label(text, skin));

    add(button);
    button.setDisabled(true);
    TextTooltip t = new TextTooltip(tooltip, skin);
    button.addListener(t);
}
项目:bladecoder-adventure-engine    文件:EditToolbar.java   
public EditToolbar(Skin skin) {
super();

this.skin = skin;
pad(0);

      createBtn = new ImageButton(skin);
      editBtn = new ImageButton(skin);
      deleteBtn = new ImageButton(skin);
      copyBtn = new ImageButton(skin);
      pasteBtn = new ImageButton(skin);

      addToolBarButton(createBtn, "ic_add","New", "Create a new Element");
      addToolBarButton(editBtn, "ic_edit","Edit", "Edit the selected Element");
      addToolBarButton(deleteBtn, "ic_delete","Delete", "Delete and put in the clipboard"); 
      addToolBarButton(copyBtn, "ic_copy","Copy", "Copy to the clipboard");
      addToolBarButton(pasteBtn, "ic_paste","Paste", "Paste from the clipboard");
  }
项目:bladecoder-adventure-engine    文件:EditToolbar.java   
public void addToolBarButton(ImageButton button, String icon, String text, String tooltip) {

    TextureRegion image = Ctx.assetManager.getIcon(icon);
    TextureRegion imageDisabled = Ctx.assetManager.getIcon(icon + "_disabled");

    ImageButtonStyle style = new ImageButtonStyle(skin.get("plain", ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(image);

    if(imageDisabled != null)
        style.imageDisabled = new TextureRegionDrawable(imageDisabled);
    button.setStyle(style);
    button.pad(6,3,6,3);
       addActor(button);
       button.setDisabled(true);
       TextTooltip t = new TextTooltip(tooltip, skin);
    button.addListener(t);
}
项目:bladecoder-adventure-engine    文件:ChapterList.java   
public ChapterList(Skin skin) {
    super(skin);

    list.setCellRenderer(listCellRenderer);

    initBtn = new ImageButton(skin);
    toolbar.addToolBarButton(initBtn, "ic_check", "Set init chapter",
            "Set init chapter");

    initBtn.setDisabled(false);
    toolbar.hideCopyPaste();

    initBtn.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            setDefault();
        }
    });

}