Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.ImageButton#ImageButtonStyle
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.ImageButton#ImageButtonStyle .
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: CCButtonTest.java From cocos-ui-libgdx with Apache License 2.0 | 6 votes |
@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)); }
Example 2
Source File: ItemBox.java From TerraLegion with MIT License | 6 votes |
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); }
Example 3
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 4
Source File: ResourceManager.java From Unlucky with MIT License | 5 votes |
/** * Loads the ImageButton styles for buttons with up and down image effects * * @param numButtons * @param sprites * @return a style array for ImageButtons */ public ImageButton.ImageButtonStyle[] loadImageButtonStyles(int numButtons, TextureRegion[][] sprites) { ImageButton.ImageButtonStyle[] ret = new ImageButton.ImageButtonStyle[numButtons]; for (int i = 0; i < numButtons; i++) { ret[i] = new ImageButton.ImageButtonStyle(); ret[i].imageUp = new TextureRegionDrawable(sprites[0][i]); ret[i].imageDown = new TextureRegionDrawable(sprites[1][i]); } return ret; }
Example 5
Source File: MenuExtensionScreen.java From Unlucky with MIT License | 5 votes |
public MenuExtensionScreen(final Unlucky game, final ResourceManager rm) { super(game, rm); // init exit button ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle(); style.imageUp = new TextureRegionDrawable(rm.menuExitButton[0][0]); style.imageDown = new TextureRegionDrawable(rm.menuExitButton[1][0]); exitButton = new ImageButton(style); exitButton.setSize(18, 18); exitButton.setPosition(177, 99); }
Example 6
Source File: ImageButtons.java From Cubes with MIT License | 4 votes |
public static ImageButton.ImageButtonStyle inventoryModifierButton() { TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/InventoryModifierButtonUp.png")); TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/InventoryModifierButtonDown.png")); return new ImageButton.ImageButtonStyle(up, down, null, null, null, null); }
Example 7
Source File: Theme.java From Klooni1010 with GNU General Public License v3.0 | 4 votes |
private Theme() { buttonStyles = new ImageButton.ImageButtonStyle[4]; }
Example 8
Source File: ImageButtons.java From Cubes with MIT License | 4 votes |
public static ImageButton.ImageButtonStyle debugButton() { TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/DebugButtonUp.png")); TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/DebugButtonDown.png")); return new ImageButton.ImageButtonStyle(up, down, null, null, null, null); }
Example 9
Source File: ImageButtons.java From Cubes with MIT License | 4 votes |
public static ImageButton.ImageButtonStyle chatButton() { TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/ChatButtonUp.png")); TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/ChatButtonDown.png")); return new ImageButton.ImageButtonStyle(up, down, null, null, null, null); }
Example 10
Source File: ImageButtons.java From Cubes with MIT License | 4 votes |
public static ImageButton.ImageButtonStyle blocksButton() { TextureRegionDrawable up = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/BlocksButtonUp.png")); TextureRegionDrawable down = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/BlocksButtonDown.png")); return new ImageButton.ImageButtonStyle(up, down, null, null, null, null); }
Example 11
Source File: ImageButtons.java From Cubes with MIT License | 4 votes |
public static ImageButton.ImageButtonStyle descendButton() { TextureRegionDrawable t = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/DescendButton.png")); return new ImageButton.ImageButtonStyle(t, t, null, null, null, null); }
Example 12
Source File: ImageButtons.java From Cubes with MIT License | 4 votes |
public static ImageButton.ImageButtonStyle jumpButton() { TextureRegionDrawable t = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/touch/JumpButton.png")); return new ImageButton.ImageButtonStyle(t, t, null, null, null, null); }
Example 13
Source File: LevelUpScreen.java From Unlucky with MIT License | 4 votes |
public LevelUpScreen(GameScreen gameScreen, TileMap tileMap, Player player, ResourceManager rm) { super(gameScreen, tileMap, player, rm); // create bg ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle(); style.imageUp = new TextureRegionDrawable(rm.levelupscreen400x240); ui = new ImageButton(style); ui.setSize(200, 120); ui.setPosition(0, 0); ui.setTouchable(Touchable.disabled); stage.addActor(ui); handleClick(); // create animation levelUpAnim = new AnimationManager(rm.levelUp96x96, 4, 0, 1 / 4f); // create labels BitmapFont font = rm.pixel10; Label.LabelStyle titleFont = new Label.LabelStyle(font, new Color(0, 205 / 255.f, 20 / 255.f, 1)); Label.LabelStyle stdWhite = new Label.LabelStyle(font, new Color(1, 1, 1, 1)); Label.LabelStyle yellow = new Label.LabelStyle(font, new Color(1, 212 / 255.f, 0, 1)); Label.LabelStyle blue = new Label.LabelStyle(font, new Color(0, 190 / 255.f, 1, 1)); title = new Label("LEVEL UP!", titleFont); title.setSize(200, 20); title.setPosition(0, 95); title.setFontScale(2.5f); title.setAlignment(Align.center); title.setTouchable(Touchable.disabled); stage.addActor(title); levelDesc = new Label("You reached level 1", stdWhite); levelDesc.setSize(200, 20); levelDesc.setPosition(0, 80); levelDesc.setAlignment(Align.center); levelDesc.setTouchable(Touchable.disabled); stage.addActor(levelDesc); statsDescs = new Label[statNames.length]; stats = new Label[statNames.length]; increases = new Label[statNames.length]; for (int i = 0; i < statNames.length; i++) { statsDescs[i] = new Label(statNames[i], stdWhite); statsDescs[i].setSize(10, 10); statsDescs[i].setFontScale(1.3f / 2); statsDescs[i].setPosition(100, 17 + (i * 12)); statsDescs[i].setAlignment(Align.left); statsDescs[i].setTouchable(Touchable.disabled); stage.addActor(statsDescs[i]); stats[i] = new Label("1330", blue); stats[i].setSize(10, 10); stats[i].setFontScale(1.3f / 2); stats[i].setPosition(140, 17 + (i * 12)); stats[i].setAlignment(Align.left); stats[i].setTouchable(Touchable.disabled); stage.addActor(stats[i]); increases[i] = new Label("+20", yellow); increases[i].setSize(10, 10); increases[i].setFontScale(1.3f / 2); increases[i].setPosition(170, 17 + (i * 12)); increases[i].setAlignment(Align.left); increases[i].setTouchable(Touchable.disabled); stage.addActor(increases[i]); } clickToContinue = new Label("Click to continue", stdWhite); clickToContinue.setSize(200, 10); clickToContinue.setFontScale(0.5f); clickToContinue.setPosition(0, 2); clickToContinue.setAlignment(Align.center); clickToContinue.setTouchable(Touchable.disabled); stage.addActor(clickToContinue); }
Example 14
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(); }
Example 15
Source File: MoveUI.java From Unlucky with MIT License | 4 votes |
/** * Creates the UI for the Run and ______ buttons * Run will have some random low percentage to escape the battle */ private void createOptionUI() { // make buttons optionButtons = new ImageButton[2]; disabled = new ImageButton.ImageButtonStyle[2]; optionStyles = rm.loadImageButtonStyles(2, rm.stdmedbutton110x50); for (int i = 0; i < 2; i++) { optionButtons[i] = new ImageButton(optionStyles[1 - i]); disabled[i] = new ImageButton.ImageButtonStyle(); disabled[i].imageUp = new TextureRegionDrawable(rm.stdmedbutton110x50[1][1 - i]); } // set pos // ____ button optionButtons[0].setPosition(2 * Util.MOVE_WIDTH, Util.MOVE_HEIGHT); // run button optionButtons[1].setPosition(2 * Util.MOVE_WIDTH, 0); // make labels optionNameLabels = new Label[2]; optionDescLabels = new Label[2]; BitmapFont bitmapFont = rm.pixel10; Label.LabelStyle font = new Label.LabelStyle(bitmapFont, new Color(255, 255, 255, 255)); optionNameLabels[0] = new Label("", font); optionNameLabels[0].setAlignment(Align.topLeft); optionNameLabels[0].setSize(55, 25); optionNameLabels[0].setFontScale(0.62f); optionNameLabels[0].setTouchable(Touchable.disabled); optionNameLabels[0].setPosition(2 * Util.MOVE_WIDTH + 7, Util.MOVE_HEIGHT - 6); optionDescLabels[0] = new Label("", font); optionDescLabels[0].setAlignment(Align.topLeft); optionDescLabels[0].setSize(55, 25); optionDescLabels[0].setFontScale(0.7f / 2); optionDescLabels[0].setTouchable(Touchable.disabled); optionDescLabels[0].setPosition(2 * Util.MOVE_WIDTH + 7, Util.MOVE_HEIGHT - 12); optionNameLabels[1] = new Label("Run", font); optionNameLabels[1].setAlignment(Align.topLeft); optionNameLabels[1].setSize(55, 25); optionNameLabels[1].setFontScale(0.62f); optionNameLabels[1].setTouchable(Touchable.disabled); optionNameLabels[1].setPosition(2 * Util.MOVE_WIDTH + 7, -6); optionDescLabels[1] = new Label("7% chance to run\nfrom a battle", font); optionDescLabels[1].setAlignment(Align.topLeft); optionDescLabels[1].setSize(55, 25); optionDescLabels[1].setFontScale(0.7f / 2); optionDescLabels[1].setTouchable(Touchable.disabled); optionDescLabels[1].setPosition(2 * Util.MOVE_WIDTH + 7, -12); for (int i = 0; i < 2; i++) { stage.addActor(optionButtons[i]); stage.addActor(optionNameLabels[i]); stage.addActor(optionDescLabels[i]); } handleOptionEvents(); }
Example 16
Source File: Theme.java From Klooni1010 with GNU General Public License v3.0 | 4 votes |
public void updateStyle(ImageButton.ImageButtonStyle style, int styleIndex) { style.imageUp = buttonStyles[styleIndex].imageUp; style.imageDown = buttonStyles[styleIndex].imageDown; }
Example 17
Source File: Theme.java From Klooni1010 with GNU General Public License v3.0 | 4 votes |
public ImageButton.ImageButtonStyle getStyle(int button) { return buttonStyles[button]; }
Example 18
Source File: Theme.java From Klooni1010 with GNU General Public License v3.0 | 4 votes |
private Theme update(final FileHandle handle) { if (skin == null) { throw new NullPointerException("A Theme.skin must be set before updating any Theme instance"); } final JsonValue json = new JsonReader().parse(handle.readString()); name = handle.nameWithoutExtension(); displayName = json.getString("name"); price = json.getInt("price"); JsonValue colors = json.get("colors"); // Java won't allow unsigned integers, we need to use Long background = new Color((int) Long.parseLong(colors.getString("background"), 16)); foreground = new Color((int) Long.parseLong(colors.getString("foreground"), 16)); JsonValue buttonColors = colors.get("buttons"); Color[] buttons = new Color[buttonColors.size]; for (int i = 0; i < buttons.length; ++i) { buttons[i] = new Color((int) Long.parseLong(buttonColors.getString(i), 16)); if (buttonStyles[i] == null) { buttonStyles[i] = new ImageButton.ImageButtonStyle(); } // Update the style. Since every button uses an instance from this // array, the changes will appear on screen automatically. buttonStyles[i].up = skin.newDrawable("button_up", buttons[i]); buttonStyles[i].down = skin.newDrawable("button_down", buttons[i]); } currentScore = new Color((int) Long.parseLong(colors.getString("current_score"), 16)); highScore = new Color((int) Long.parseLong(colors.getString("high_score"), 16)); bonus = new Color((int) Long.parseLong(colors.getString("bonus"), 16)); bandColor = new Color((int) Long.parseLong(colors.getString("band"), 16)); textColor = new Color((int) Long.parseLong(colors.getString("text"), 16)); emptyCell = new Color((int) Long.parseLong(colors.getString("empty_cell"), 16)); JsonValue cellColors = colors.get("cells"); cells = new Color[cellColors.size]; for (int i = 0; i < cells.length; ++i) { cells[i] = new Color((int) Long.parseLong(cellColors.getString(i), 16)); } String cellTextureFile = json.getString("cell_texture"); cellTexture = SkinLoader.loadPng("cells/" + cellTextureFile); return this; }