Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.ImageButton#setSize()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.ImageButton#setSize() .
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: 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 2
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 3
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); }