当前位置: 首页>>代码示例>>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;未经允许,请勿转载。