本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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));
}
});
}
示例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);
}
}
示例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;
}
示例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));
}
});
}
示例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));
}
});
}
示例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));
}
});
}
示例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();
}
});
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}