List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Align top
int top
To view the source code for com.badlogic.gdx.scenes.scene2d.utils Align top.
Click Source Link
From source file:ac.uk.dmu.ash.game.screen.CreditsScreen.java
License:Open Source License
/** * Creates a new {@link CreditsScreen}./*w w w .java 2s .c om*/ * @param game The game instance. * @param assets The game assets */ public CreditsScreen(final Game game, final AssetManager assets) { this.assets = assets; Gdx.input.setInputProcessor(stage); Table fpsTable = createTableWithLabel(assets, "ui_skin", Align.left, (Align.top | Align.left), "fps:"); fpsLabel = (Label) fpsTable.getCells().get(0).getWidget(); stage.addActor(fpsTable); Table creditsTable = createTableWithLabel(assets, "ui_skin", CREDITS); stage.addActor(creditsTable); TextButton backButton = createTextButton(assets, "ui_skin", "Back", new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { dispose(); game.setScreen(new MainMenuScreen(game, assets)); } }); Table buttonsTable = createTable(Align.left | Align.bottom); buttonsTable.add(backButton); stage.addActor(buttonsTable); }
From source file:com.aia.hichef.ui.n.MyWindow.java
License:Apache License
public MyWindow(String title, WindowStyle style) { if (title == null) throw new IllegalArgumentException("title cannot be null."); this.title = title; setTouchable(Touchable.enabled);// w ww.ja v a2 s.co m setClip(true); setStyle(style); setWidth(150); setHeight(150); setTitle(title); setHeight(100); buttonTable = new Table(); addActor(buttonTable); addCaptureListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { toFront(); return false; } }); addListener(new InputListener() { int edge; float startX, startY, lastX, lastY; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (button == 0) { int border = resizeBorder; float width = getWidth(), height = getHeight(); edge = 0; if (isResizable) { if (x < border) edge |= Align.left; if (x > width - border) edge |= Align.right; if (y < border) edge |= Align.bottom; if (y > height - border) edge |= Align.top; if (edge != 0) border += 25; if (x < border) edge |= Align.left; if (x > width - border) edge |= Align.right; if (y < border) edge |= Align.bottom; if (y > height - border) edge |= Align.top; } if (isMovable && edge == 0 && y <= height && y >= height - getPadTop() && x >= 0 && x <= width) edge = MOVE; dragging = edge != 0; startX = x; startY = y; lastX = x; lastY = y; } return edge != 0 || isModal; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { dragging = false; } public void touchDragged(InputEvent event, float x, float y, int pointer) { if (!dragging) return; float width = getWidth(), height = getHeight(); float windowX = getX(), windowY = getY(); float minWidth = getMinWidth(), maxWidth = getMaxWidth(); float minHeight = getMinHeight(), maxHeight = getMaxHeight(); Stage stage = getStage(); boolean clampPosition = keepWithinStage && getParent() == stage.getRoot(); if ((edge & MOVE) != 0) { float amountX = x - startX, amountY = y - startY; windowX += amountX; windowY += amountY; } if ((edge & Align.left) != 0) { float amountX = x - startX; if (width - amountX < minWidth) amountX = -(minWidth - width); if (clampPosition && windowX + amountX < 0) amountX = -windowX; width -= amountX; windowX += amountX; } if ((edge & Align.bottom) != 0) { float amountY = y - startY; if (height - amountY < minHeight) amountY = -(minHeight - height); if (clampPosition && windowY + amountY < 0) amountY = -windowY; height -= amountY; windowY += amountY; } if ((edge & Align.right) != 0) { float amountX = x - lastX; if (width + amountX < minWidth) amountX = minWidth - width; if (clampPosition && windowX + width + amountX > stage.getWidth()) amountX = stage.getWidth() - windowX - width; width += amountX; } if ((edge & Align.top) != 0) { float amountY = y - lastY; if (height + amountY < minHeight) amountY = minHeight - height; if (clampPosition && windowY + height + amountY > stage.getHeight()) amountY = stage.getHeight() - windowY - height; height += amountY; } lastX = x; lastY = y; setBounds(Math.round(windowX), Math.round(windowY), Math.round(width), Math.round(height)); } public boolean mouseMoved(InputEvent event, float x, float y) { return isModal; } public boolean scrolled(InputEvent event, float x, float y, int amount) { return isModal; } public boolean keyDown(InputEvent event, int keycode) { return isModal; } public boolean keyUp(InputEvent event, int keycode) { return isModal; } public boolean keyTyped(InputEvent event, char character) { return isModal; } }); }
From source file:com.aia.hichef.ui.n.MyWindow.java
License:Apache License
protected void drawBackground(Batch batch, float parentAlpha, float x, float y) { float width = getWidth(), height = getHeight(); float padTop = getPadTop(); super.drawBackground(batch, parentAlpha, x, y); // Draw button table. buttonTable.getColor().a = getColor().a; buttonTable.pack();//from ww w.jav a2 s. c o m buttonTable.setPosition(width - buttonTable.getWidth(), Math.min(height - padTop, height - buttonTable.getHeight())); buttonTable.draw(batch, parentAlpha); // Draw the title without the batch transformed or clipping applied. y += height; TextBounds bounds = titleCache.getBounds(); if ((titleAlignment & Align.left) != 0) x += getPadLeft(); else if ((titleAlignment & Align.right) != 0) x += width - bounds.width - getPadRight(); else x += (width - bounds.width) / 2; if ((titleAlignment & Align.top) == 0) { if ((titleAlignment & Align.bottom) != 0) y -= padTop - bounds.height; else y -= (padTop - bounds.height) / 2; } titleCache.setColors(Color.tmp.set(getColor()).mul(style.titleFontColor)); titleCache.setPosition((int) x, (int) y); titleCache.draw(batch, parentAlpha); }
From source file:com.badlogic.gdx.spriter.demo.SpriterDemoApp.java
@Override public void create() { // Initialize object batch = new SpriteBatch(); camera = new OrthographicCamera(); FileHandleResolver resolver = new InternalFileHandleResolver(); assetManager = new AssetManager(resolver); assetManager.setLoader(SpriterData.class, new SpriterDataLoader(resolver)); resolver = new AbsoluteFileHandleResolver(); externalAssetManager = new AssetManager(resolver); externalAssetManager.setLoader(SpriterData.class, new SpriterDataLoader(resolver)); assetManager.load("uiskin.json", Skin.class); assetManager.finishLoading();/*from w w w . j a va 2 s . c om*/ skin = assetManager.get("uiskin.json"); // Create widgets stage = new Stage(new ScreenViewport(camera), batch); Label titleLabel = new Label("gdx-spriter", skin); titleLabel.setFontScale(3f); Label fpsLabel = new Label("FPS", skin) { @Override public void act(float delta) { this.setText(Gdx.graphics.getFramesPerSecond() + " FPS"); super.act(delta); } }; fileChooser = new SelectBox<SpriterDemoFileHandle>(skin); fileChooser.setName("Files"); fileChooser.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { changeSpriterFile(fileChooser.getSelected()); lastUsedSelectBox = fileChooser; } }); Button fileFinder = new TextButton("Browse", skin); fileFinder.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { FileDialog fileDialog = new FileDialog((java.awt.Frame) null, "Choose Spriter file", FileDialog.LOAD); fileDialog.setDirectory(lastFolderBrowsed); fileDialog.setResizable(true); fileDialog.setVisible(true); String file = fileDialog.getFile(); String directory = fileDialog.getDirectory(); if (directory != null) { lastFolderBrowsed = directory; } if (file != null) { String path = directory + file; addFile(Gdx.files.absolute(path), externalAssetManager); fileChooser.setItems(files); fileChooser.setSelectedIndex(fileChooser.getItems().size - 1); } } }); entityChooser = new SelectBox<SpriterAnimator>(skin); entityChooser.setName("Entities"); entityChooser.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { changeAnimator(entityChooser.getSelected()); lastUsedSelectBox = entityChooser; } }); animationChooser = new SelectBox<String>(skin); animationChooser.setName("Animations"); animationChooser.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { changeAnimation(animationChooser.getSelected()); lastUsedSelectBox = animationChooser; } }); final CheckBox transitionCheckbox = new CheckBox("Transition", skin); transitionCheckbox.setChecked(transition); transitionCheckbox.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { transition = transitionCheckbox.isChecked(); } }); charmapChooser = new List<SpriterCharacterMap>(skin); ArraySelection<SpriterCharacterMap> selection = charmapChooser.getSelection(); selection.setMultiple(true); selection.setRangeSelect(false); selection.setToggle(false); selection.setRequired(false); charmapChooser.setName("Charmaps"); charmapChooser.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { changeCharacterMaps(charmapChooser.getSelection().items().orderedItems()); } }); angleSlider = new SpriterDemoAnimatorSlider(0, 360, 1f, skin, "%.0f") { @Override public void setValue(SpriterAnimator animator, float value) { spriterAnimator.setRotation(value); } @Override protected float getValue(SpriterAnimator animator) { return spriterAnimator.getRotation(); } }; pivotXSlider = new SpriterDemoAnimatorSlider(-1000f, 1000f, 1f, skin, "%.0f") { @Override public void setValue(SpriterAnimator animator, float value) { animator.setPivotX(value); } @Override protected float getValue(SpriterAnimator animator) { return animator.getPivotX(); } }; pivotYSlider = new SpriterDemoAnimatorSlider(-1000f, 1000f, 1f, skin, "%.0f") { @Override public void setValue(SpriterAnimator animator, float value) { animator.setPivotY(value); } @Override protected float getValue(SpriterAnimator animator) { return animator.getPivotY(); } }; scaleXSlider = new SpriterDemoAnimatorSlider(-10f, 10f, 0.1f, skin) { @Override public void setValue(SpriterAnimator animator, float value) { spriterAnimator.setScaleX(value); } @Override protected float getValue(SpriterAnimator animator) { return spriterAnimator.getScaleX(); } }; scaleYSlider = new SpriterDemoAnimatorSlider(-10f, 10f, 0.1f, skin) { @Override public void setValue(SpriterAnimator animator, float value) { spriterAnimator.setScaleY(value); } @Override protected float getValue(SpriterAnimator animator) { return spriterAnimator.getScaleY(); } }; alphaSlider = new SpriterDemoAnimatorSlider(0f, 1f, 0.01f, skin, "%.2f") { @Override public void setValue(SpriterAnimator animator, float value) { animator.setAlpha(value); } @Override protected float getValue(SpriterAnimator animator) { return animator.getAlpha(); } }; speedSlider = new SpriterDemoAnimatorSlider(0f, 10f, 0.1f, skin) { @Override public void setValue(SpriterAnimator animator, float value) { animator.setSpeed(value); } @Override protected float getValue(SpriterAnimator animator) { return animator.getSpeed(); } }; allAnimatorSliders = new SpriterDemoAnimatorSlider[] { scaleXSlider, scaleYSlider, pivotXSlider, pivotYSlider, angleSlider, alphaSlider, speedSlider }; metaLabel = new Label("Meta: ", skin); metaLabel.setWrap(true); metaLabel.setAlignment(Align.topLeft); spriterPlaceholder = new Label("No animator", skin); spriterPlaceholder.setAlignment(Align.center); spriterAnimator = new SpriterAnimatorActor(animator); spriterAnimator.debug(); playPauseButton = new ImageButton(skin, "play"); playPauseButton.setChecked(true); playPauseButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { boolean playing = playPauseButton.isChecked(); spriterAnimator.setDisabled(!playing); } }); timeSlider = new Slider(0f, 2000f, 1, false, skin); timeSlider.addListener(timeSliderListener = new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (animator == null) return; animator.setTime(timeSlider.getValue()); animator.update(0f); } }); timeLabel = new Label("---", skin); // Put everything in place Table titleTable = new Table(skin); titleTable.add(titleLabel).pad(6f); titleTable.add().expandX(); titleTable.add(fpsLabel).padRight(10f); Table selectionTable = new Table(skin); selectionTable.defaults().pad(3f); Table filesTable = new Table(skin); filesTable.row(); filesTable.add(fileChooser).expand().fillX(); filesTable.add(fileFinder).padLeft(2f).padRight(1f); Table animationsTable = new Table(skin); animationsTable.row(); animationsTable.add(animationChooser).expand().fill(); animationsTable.add(transitionCheckbox).fillX().padLeft(2f); ScrollPane scrollableCharmapChooser = new ScrollPane(charmapChooser); Table menuTable = new Table(skin); menuTable.defaults().pad(3f).expandX().fillX(); menuTable.row(); menuTable.add(titleTable).colspan(2); menuTable.row(); menuTable.add("File"); menuTable.add(filesTable).pad(4f); menuTable.row(); menuTable.add("Entity"); menuTable.add(entityChooser).pad(4f); menuTable.row(); menuTable.add("Animation"); menuTable.add(animationsTable).pad(4f); menuTable.row(); menuTable.add("Maps"); menuTable.add(scrollableCharmapChooser).pad(4f); menuTable.row(); menuTable.add("Angle"); menuTable.add(angleSlider); menuTable.row(); menuTable.add("Pivot X"); menuTable.add(pivotXSlider); menuTable.row(); menuTable.add("Pivot Y"); menuTable.add(pivotYSlider); menuTable.row(); menuTable.add("Scale X"); menuTable.add(scaleXSlider); menuTable.row(); menuTable.add("Scale Y"); menuTable.add(scaleYSlider); menuTable.row(); menuTable.add("Alpha"); menuTable.add(alphaSlider); menuTable.row(); menuTable.add("Speed"); menuTable.add(speedSlider); menuTable.row(); menuTable.add().expandY(); Table contentTable = new Table(skin); contentTable.row(); contentTable.add(metaLabel).left().expandX().maxHeight(1f); contentTable.row(); contentTable.stack(spriterPlaceholder, spriterAnimator).expand(); Table timelineTable = new Table(skin); timelineTable.row(); timelineTable.add("Timeline").expandX().align(Align.bottom); timelineTable.row(); timelineTable.add(timeSlider).expandX().fillX(); timelineTable.row(); timelineTable.add(timeLabel).expandX().align(Align.top); Table controlTable = new Table(skin); controlTable.add(playPauseButton).space(5f).expandY().fillY(); controlTable.add(timelineTable).expandX().fillX(); rootTable = new Table(skin); rootTable.setFillParent(true); rootTable.row(); rootTable.add(menuTable).expandY().fill(); rootTable.add(contentTable).expand().fill(); rootTable.row(); rootTable.add(controlTable).colspan(2).expandX().fillX(); stage.addActor(rootTable); // Bring input processing to the party InputProcessor globalInput = new InputProcessor() { @Override public boolean keyDown(int keycode) { switch (keycode) { case Keys.UP: case Keys.Z: case Keys.W: if (lastUsedSelectBox != null) lastUsedSelectBox.setSelectedIndex(Math.max(lastUsedSelectBox.getSelectedIndex() - 1, 0)); break; case Keys.DOWN: case Keys.S: if (lastUsedSelectBox != null) lastUsedSelectBox.setSelectedIndex(Math.min(lastUsedSelectBox.getSelectedIndex() + 1, lastUsedSelectBox.getItems().size - 1)); break; default: break; } return true; } @Override public boolean keyUp(int keycode) { return false; } @Override public boolean keyTyped(char character) { return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { return false; } @Override public boolean mouseMoved(int screenX, int screenY) { return false; } @Override public boolean scrolled(int amount) { amount *= 0.05f; // Zoom coefficient scaleXSlider.setValue(scaleXSlider.getValue() + amount); scaleYSlider.setValue(scaleYSlider.getValue() + amount); return false; } }; Gdx.input.setInputProcessor(new InputMultiplexer(stage, globalInput)); // Add default test resources Array<String> testResources = new Array<String>(SpriterTestData.scml); testResources.addAll(SpriterTestData.scon); testResources.sort(); for (String path : testResources) addFile(Gdx.files.internal(path.replaceFirst("/", "")), assetManager); // Also go discover some unknown exotic resources! (won't work in jar though) Array<FileHandle> spriterFiles = SpriterDemoUtils.findFiles(new String[] { "scml", "scon" }); for (FileHandle f : spriterFiles) addFile(f, assetManager); fileChooser.setItems(files); lastUsedSelectBox = fileChooser; if (playPauseButton.isChecked()) animator.play(animator.getAnimations().iterator().next()); }
From source file:com.badlogic.gdx.tests.BulletTestCollection.java
License:Apache License
@Override public void create() { if (app == null) { app = Gdx.app;//from w w w.j ava 2s . c o m tests[testIndex].create(); } cameraController = new CameraInputController(tests[testIndex].camera); cameraController.activateKey = Keys.CONTROL_LEFT; cameraController.autoUpdate = false; cameraController.forwardTarget = false; cameraController.translateTarget = false; Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this))); font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false); hud = new Stage(); hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE))); fpsLabel.setPosition(0, 0); hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE))); titleLabel.setY(hud.getHeight() - titleLabel.getHeight()); hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE))); instructLabel.setY(titleLabel.getY() - instructLabel.getHeight()); instructLabel.setAlignment(Align.top | Align.left); instructLabel.setText(tests[testIndex].instructions); }
From source file:com.gdx.extension.ui.grid.GridSelection.java
License:Apache License
/** * Create a {@link GridSelection} with defined parameters. * // ww w . j ava 2 s. com * @param isVertical If {@link GridSelection} should be constructed and scrolled vertically or not * @param itemCount Number of columns if isVertical is true or number of rows if isVertical is false */ public GridSelection(boolean isVertical, int itemCount) { super(); this.isVertical = isVertical; align(Align.left + Align.top); gridItemGroup = new ActorGroup<T>(); gridItemGroup.setMinCheckCount(1); setSelectionMode(SelectionMode.SINGLE); if (isVertical) { columns = new Array<VerticalGroup>(); for (int i = 0; i < itemCount; i++) addColumn(); } else { rows = new Array<HorizontalGroup>(); for (int i = 0; i < itemCount; i++) addRow(); } }
From source file:com.jmstudios.pointandhit.OptionsScreen.java
License:Open Source License
public OptionsScreen(final OneShotGame game) { this.game = game; this.scale = game.scale; Vector2 screenSize = new Vector2(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Font// ww w .ja va 2 s. co m textFont = new BitmapFont(Gdx.files.internal("fonts/deja_vu_sans_medium.fnt")); textFont.setScale(scale); BitmapFont titleFont = new BitmapFont(Gdx.files.internal("fonts/deja_vu_sans_large.fnt")); titleFont.setScale(scale); // Checkbox style Texture checkBoxes = new Texture(Gdx.files.internal("buttons/radiobutton.png")); TextureRegionDrawable checkBoxUnchecked = new TextureRegionDrawable( new TextureRegion(checkBoxes, 0, 0, 64, 64)); TextureRegionDrawable checkBoxChecked = new TextureRegionDrawable( new TextureRegion(checkBoxes, 64, 0, 64, 64)); checkBoxStyle = new CheckBox.CheckBoxStyle(checkBoxUnchecked, checkBoxChecked, textFont, Color.WHITE); CheckBox verySensitive = newRadioButton("Very sensitive"), sensitive = newRadioButton("Sensitive"), normal = newRadioButton("Normal"), forgiving = newRadioButton("Forgiving"), veryForgiving = newRadioButton("Very forgiving"), invertControls = newRadioButton("Invert the controls"); sensitivityGroup = new ButtonGroup<CheckBox>(verySensitive, sensitive, normal, forgiving, veryForgiving, invertControls); int startSetting = game.preferences.getInteger("sensitivity", 2); sensitivityGroup.uncheckAll(); sensitivityGroup.getButtons().get(startSetting).setChecked(true); float padding = 20 * scale; // Title Table titleTable = new Table(); titleTable.align(Align.topLeft); Pixmap backgroundPixmap = new Pixmap(1, 1, Format.RGBA8888); backgroundPixmap.setColor(new Color(0.9f, 0.35f, 0.1f, 1)); backgroundPixmap.fill(); titleTable.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(backgroundPixmap)))); Label.LabelStyle titleLabelStyle = new Label.LabelStyle(titleFont, Color.WHITE); Label titleLabel = new Label("Control sensitivity", titleLabelStyle); titleLabel.setWrap(true); titleLabel.setWidth(screenSize.x - padding * 2); titleLabel.setAlignment(Align.center); titleTable.add(titleLabel).align(Align.topLeft).pad(2 * padding).width(screenSize.x - padding * 2); // Checkboxes optionsTable = new Table(); optionsTable.align(Align.topLeft); optionsTable.defaults().align(Align.topLeft).pad(padding).padBottom(0).padLeft(2 * padding); optionsTable.row(); optionsTable.add(verySensitive); optionsTable.row(); optionsTable.add(sensitive); optionsTable.row(); optionsTable.add(normal); optionsTable.row(); optionsTable.add(forgiving); optionsTable.row(); optionsTable.add(veryForgiving); optionsTable.row(); optionsTable.add(invertControls); optionsTable.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { int newSensitivity = sensitivityGroup.getCheckedIndex(); if (newSensitivity == -1) newSensitivity = 2; game.preferences.putInteger("sensitivity", newSensitivity); game.preferences.flush(); } }); mainTable = new Table(); mainTable.setFillParent(true); mainTable.align(Align.top); mainTable.add(titleTable).pad(0).padBottom(padding * 4).fill(10, 1).align(Align.topLeft); mainTable.row(); mainTable.add(optionsTable).align(Align.left); mainStage = new Stage(); mainStage.addActor(mainTable); // Input inputMultiplexer = new InputMultiplexer(); inputMultiplexer.addProcessor(mainStage); inputMultiplexer.addProcessor(this); }
From source file:com.ladinc.core.screens.GameScreenLobby.java
License:Creative Commons License
private Table createMainTable() { Table mainTable = new Table(); //mainTable.debug(); mainTable.setWidth(screenWidth);/*from w w w. j a v a 2 s .co m*/ mainTable.add(createTitleTable()).colspan(2).padTop(50f).padBottom(70f).align(Align.top); mainTable.row(); mainTable.add(createStepTable()).padBottom(60f).width(Value.percentWidth(0.75f, mainTable)).expandY() .align(Align.top); mainTable.add(createConnectedPlayersTable()).align(Align.top).expandX(); mainTable.row(); createBottomRow(mainTable); return mainTable; }
From source file:com.ladinc.core.screens.GameScreenLobby.java
License:Creative Commons License
private Table createStepTable() { Table stepTable = new Table(); stepTable.add(new Label("To Join The Game", new Label.LabelStyle(font, Color.ORANGE))).colspan(2) .padBottom(60f);/*from w w w.ja v a 2 s. c o m*/ stepTable.row(); stepTable.add(createStep1Table()).align(Align.top).width(Value.percentWidth(0.45f, stepTable)); stepTable.add(createStep2Table()).align(Align.top | Align.right) .width(Value.percentWidth(0.55f, stepTable)); return stepTable; }
From source file:com.ladinc.core.screens.GameScreenLobby.java
License:Creative Commons License
private void createBottomRow(Table table) { Table bottomTable = table;//from ww w . j a v a 2s .c om String text; if (creditsButton == null) { TextButtonStyle style = new TextButtonStyle(); //** Button properties **// style.up = buttomDrawable; style.down = buttomPressedDrawable; style.font = smallFont; style.fontColor = Color.GRAY; String buttonText = "Credits"; if (this.game.gcm.useOptionButtonText) { buttonText = buttonText + " " + this.game.gcm.leftFaceButtonText; } creditsButton = new TextButton(buttonText, style); creditsButton.setBounds(creditsButton.getX(), creditsButton.getY(), creditsButton.getWidth(), creditsButton.getHeight()); creditsButton.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { displayCredits = true; return true; } }); creditsButton.padLeft(8f); creditsButton.padRight(8f); creditsButton.padTop(5f); creditsButton.padBottom(5f); } if (this.game.players.size() < 3) { text = "Waiting for players to connect ( " + (3 - this.game.players.size()) + " more needed )"; } else { text = "Ready to start"; } bottomTable.add(new Label(text, new Label.LabelStyle(font, Color.WHITE))).padBottom(70f); bottomTable.add(creditsButton).align(Align.top).padTop(10f); }