Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.ImageButton#addListener()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.ImageButton#addListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameSpeedController.java From GdxDemo3D with Apache License 2.0 | 6 votes |
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(); } }); }
Example 2
Source File: ProjectToolbar.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
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); }
Example 3
Source File: EditToolbar.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: ChapterList.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
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(); } }); }
Example 5
Source File: WidgetsBar.java From gdx-skineditor with Apache License 2.0 | 5 votes |
/** * */ 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); } }
Example 6
Source File: InventoryUI.java From Unlucky with MIT License | 4 votes |
public InventoryUI(final Unlucky game, Player player, final ResourceManager rm) { super(game, player, rm); ui = new MovingImageUI(rm.inventoryui372x212, new Vector2(200, 7), new Vector2(7, 7), 225.f, 186, 106); ui.setTouchable(Touchable.enabled); // create exit button ImageButton.ImageButtonStyle exitStyle = new ImageButton.ImageButtonStyle(); exitStyle.imageUp = new TextureRegionDrawable(rm.exitbutton18x18[0][0]); exitStyle.imageDown = new TextureRegionDrawable(rm.exitbutton18x18[1][0]); exitButton = new ImageButton(exitStyle); exitButton.setSize(9, 9); // Fonts and Colors Label.LabelStyle[] labelColors = new Label.LabelStyle[] { new Label.LabelStyle(rm.pixel10, new Color(1, 1, 1, 1)), // white new Label.LabelStyle(rm.pixel10, new Color(0, 190 / 255.f, 1, 1)), // blue new Label.LabelStyle(rm.pixel10, new Color(1, 212 / 255.f, 0, 1)), // yellow new Label.LabelStyle(rm.pixel10, new Color(0, 1, 60 / 255.f, 1)), // green new Label.LabelStyle(rm.pixel10, new Color(220 / 255.f, 0, 0, 1)) // red }; // create headers headers = new Label[3]; for (int i = 0; i < headers.length; i++) { headers[i] = new Label(headerStrs[i], labelColors[0]); headers[i].setSize(62, 4); headers[i].setFontScale(0.5f); headers[i].setTouchable(Touchable.disabled); headers[i].setAlignment(Align.left); } // create stats stats = new Label[5]; for (int i = 0; i < stats.length; i++) { stats[i] = new Label("", labelColors[0]); stats[i].setSize(62, 4); stats[i].setFontScale(0.5f); stats[i].setTouchable(Touchable.disabled); stats[i].setAlignment(Align.left); } stats[0].setStyle(labelColors[3]); stats[1].setStyle(labelColors[4]); stats[2].setStyle(labelColors[1]); stats[3].setStyle(labelColors[2]); stats[4].setStyle(labelColors[2]); selectedSlot = new Image(rm.selectedslot28x28); selectedSlot.setVisible(false); tooltip = new ItemTooltip(rm.skin); tooltip.setPosition(90, 15); enabled = new ImageButton.ImageButtonStyle(); enabled.imageUp = new TextureRegionDrawable(rm.invbuttons92x28[0][0]); enabled.imageDown = new TextureRegionDrawable(rm.invbuttons92x28[1][0]); disabled = new ImageButton.ImageButtonStyle(); disabled.imageUp = new TextureRegionDrawable(rm.invbuttons92x28[2][0]); invButtons = new ImageButton[2]; invButtonLabels = new Label[2]; String[] texts = { "ENCHANT", "SELL" }; for (int i = 0; i < 2; i++) { invButtons[i] = new ImageButton(disabled); invButtons[i].setTouchable(Touchable.disabled); invButtonLabels[i] = new Label(texts[i], labelColors[0]); invButtonLabels[i].setFontScale(0.5f); invButtonLabels[i].setTouchable(Touchable.disabled); invButtonLabels[i].setSize(46, 14); invButtonLabels[i].setAlignment(Align.center); } exitButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { end(); if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume); if (inMenu) { removeInventoryActors(); game.menuScreen.transitionIn = 1; renderHealthBars = false; game.inventoryScreen.setSlideScreen(game.menuScreen, true); } else { Gdx.input.setInputProcessor(gameScreen.multiplexer); } } }); handleStageEvents(); handleInvButtonEvents(); }