@Override public void resize(int width, int height) { if (stage == null) { stage = new Stage(width, height, true); } stage.clear(); Gdx.input.setInputProcessor(stage); TextButtonStyle butStyle = new TextButtonStyle(); butStyle.up = butSkin.getDrawable("butdown"); butStyle.down = butSkin.getDrawable("butup"); butStyle.font = font1; LabelStyle labelStyle = new LabelStyle(); labelStyle.font = font1; mainButton = new TextButton("Start Game!", butStyle); closeButton = new TextButton("Do nothing", butStyle); mainButton.setWidth(400); mainButton.setHeight(100); mainButton.setX(Gdx.graphics.getWidth() / 2 - mainButton.getWidth() / 2); mainButton.setY(Gdx.graphics.getHeight() / 2 - 2 * (mainButton.getHeight() / 1.2f)); closeButton.setWidth(400); closeButton.setHeight(100); closeButton.setX(Gdx.graphics.getWidth() / 2 - closeButton.getWidth() / 2); closeButton.setY( Gdx.graphics.getHeight() / 2 - 2 * (closeButton.getHeight() / 1.2f) - (closeButton.getHeight() + 5)); mainButton.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("down"); return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { golf.setCall(false); // disable splash screen after first use golf.setScreen(golf.hole, 1); } }); stage.addActor(mainButton); stage.addActor(closeButton); }
public TextButton getPlayButton() { // Generate a 1x1 white texture and store it in the skin named "white". playBtnPixmap.setColor(Color.GREEN); playBtnPixmap.fill(); skin.add("white", new Texture(playBtnPixmap)); // Store the default libgdx font under the name "default". BitmapFont bfont = new BitmapFont(); // bfont.getData().scale(1.0f);; skin.add("default", bfont); // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so // this doesn't overwrite the font. TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY); textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY); textButtonStyle.checked = skin.newDrawable("white", Color.BLUE); textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY); textButtonStyle.font = skin.getFont("default"); skin.add("default", textButtonStyle); TextButton btn = new TextButton("Play game! \nTada", textButtonStyle); btn.setX(Gdx.graphics.getWidth() / 2 - btn.getWidth() / 2); btn.setY(Gdx.graphics.getHeight() / 2); return btn; }
private void layout() { lblMsg.setHeight(50); lblMsg.setWidth(w); lblMsg.setAlignment(Align.center, Align.center); lblMsg.setWrap(true); lblMsg.setText(Msg); lblMsg.setPosition(0, h - lblMsg.getHeight()); if (WorkPathFound > 0) { btnRunTranslations.setVisible(true); if (ImageWorkPathFound) btnRunTexturePacker.setVisible(true); else btnRunTexturePacker.setVisible(false); btnRunLibGdx.setWidth(300); btnRunLibGdx.setHeight(35); btnRunLibGdx.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight()); btnRunLibGdx.setX(margin); btnRunTranslations.setWidth(300); btnRunTranslations.setHeight(35); btnRunTranslations.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight()); btnRunTranslations.setX(btnRunLibGdx.getX() + btnRunLibGdx.getWidth() + margin); btnRunTexturePacker.setWidth(300); btnRunTexturePacker.setHeight(35); btnRunTexturePacker.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight()); btnRunTexturePacker.setX(btnRunTranslations.getX() + btnRunLibGdx.getWidth() + margin); } else { btnRunTranslations.setVisible(false); btnRunTexturePacker.setVisible(false); btnRunLibGdx.setWidth(300); btnRunLibGdx.setHeight(35); btnRunLibGdx.setY(lblMsg.getY() - margin - btnRunLibGdx.getHeight()); btnRunLibGdx.setX(w / 2 - btnRunLibGdx.getWidth() / 2); } lblOut.setHeight(btnRunLibGdx.getY() - margin - margin); lblOut.setWidth(w - margin - margin); lblOut.setWrap(true); lblOut.setPosition(margin, margin); }
public TextButton get9PatchButton(String buttonText) { // Drawable tmpDrawable = skinButton.newDrawable(skinButton.getDrawable("default")); TextButton btn = new TextButton(buttonText, skinButton); // TextButton btn = new TextButton(buttonText, tmpDrawable); btn.setHeight(btn.getHeight() * 0.75f); btn.setX(Gdx.graphics.getWidth() / 2 - btn.getWidth() / 2); btn.setY(Gdx.graphics.getHeight() / 2); return btn; }