當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageButton類代碼示例

本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.ui.ImageButton的典型用法代碼示例。如果您正苦於以下問題:Java ImageButton類的具體用法?Java ImageButton怎麽用?Java ImageButton使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImageButton類屬於com.badlogic.gdx.scenes.scene2d.ui包,在下文中一共展示了ImageButton類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drawdefenders

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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);
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:20,代碼來源:ScreenCombat.java

示例2: drawAttachers

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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);
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:19,代碼來源:ScreenCombat.java

示例3: initButtons

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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);

}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:25,代碼來源:DeathScreen.java

示例4: setObjectives

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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();
    }
}
 
開發者ID:MartensCedric,項目名稱:Hexpert,代碼行數:27,代碼來源:ObjectiveDialog.java

示例5: MenuScreen

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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));
        }
    });
}
 
開發者ID:Frappagames,項目名稱:le-pendu,代碼行數:20,代碼來源:MenuScreen.java

示例6: KeyboardActor

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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);
    }
}
 
開發者ID:Frappagames,項目名稱:le-pendu,代碼行數:22,代碼來源:KeyboardActor.java

示例7: getButtons

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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;
}
 
開發者ID:janithjeewantha,項目名稱:OmiClub,代碼行數:26,代碼來源:GraphicsLoader.java

示例8: HelpButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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));
        }
    });
}
 
開發者ID:NahroTo,項目名稱:Teleport-Ball,代碼行數:20,代碼來源:HelpButton.java

示例9: PlayButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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));
        }
    });
}
 
開發者ID:NahroTo,項目名稱:Teleport-Ball,代碼行數:17,代碼來源:PlayButton.java

示例10: HomeButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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));
        }
    });
}
 
開發者ID:NahroTo,項目名稱:Teleport-Ball,代碼行數:21,代碼來源:HomeButton.java

示例11: RestartButton

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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();
        }
    });
}
 
開發者ID:NahroTo,項目名稱:Teleport-Ball,代碼行數:21,代碼來源:RestartButton.java

示例12: ButtonUI

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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();
    }
 
開發者ID:Mignet,項目名稱:Inspiration,代碼行數:24,代碼來源:ButtonUI.java

示例13: shouldParseSingleButtonWithImages

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
@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));
}
 
開發者ID:varFamily,項目名稱:cocos-ui-libgdx,代碼行數:22,代碼來源:CCButtonTest.java

示例14: ItemBox

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
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);
}
 
開發者ID:jmrapp1,項目名稱:TerraLegion,代碼行數:20,代碼來源:ItemBox.java

示例15: SliderMenuTable

import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:nkarasch,項目名稱:ChessGDX,代碼行數:26,代碼來源:SliderMenuTable.java


注:本文中的com.badlogic.gdx.scenes.scene2d.ui.ImageButton類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。