List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Align left
int left
To view the source code for com.badlogic.gdx.scenes.scene2d.utils Align left.
Click Source Link
From source file:ac.uk.dmu.ash.game.screen.CreditsScreen.java
License:Open Source License
/** * Creates a new {@link CreditsScreen}./*from w w w .j a v a2 s .com*/ * @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.ahsgaming.superrummy.screens.LevelScreen.java
License:Apache License
/** * Implemented methods// w w w . j av a 2 s . c o m */ @Override public void show() { super.show(); Gdx.app.log(RummyGame.LOG, "LevelScreen#show"); grpLevel = new Group(); grpCardArea = new Group(); for (Player p : gameController.getPlayers()) { grpLevel.addActor(p.getHand()); p.getHand().setHidden(true); p.getHand().setCompressed(true); } currentPlayer.getHand().setHidden(false); currentPlayer.getHand().setCompressed(false); grpLevel.addActor(gameController.getDeck()); grpCardArea.addActor(gameController.getDeck()); grpCardArea.addActor(gameController.getDiscards()); grpLevel.addActor(grpCardArea); gameController.getDiscards().addListener(new ClickListener() { @Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { super.enter(event, x, y, pointer, fromActor); gameController.getDiscards().setCompressed(false); } @Override public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { super.exit(event, x, y, pointer, toActor); gameController.getDiscards().setCompressed(true); } @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); gameController.buy(currentPlayer); } }); gameController.getDeck().addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); if (gameController.isCurrentPlayer(currentPlayer)) gameController.draw(currentPlayer, false); } }); controlPanel = new Table(getSkin()); stage.addActor(controlPanel); TextButton btn = new TextButton("Draw", getSkin()); controlPanel.add(btn).size(100, 50); controlPanel.align(Align.left + Align.bottom); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); if (gameController.isCurrentPlayer(currentPlayer)) gameController.draw(currentPlayer, false); } }); btn = new TextButton("Meld", getSkin()); controlPanel.add(btn).size(100, 50); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); activateMeldMode(); } }); controlPanel.row(); btn = new TextButton("Buy", getSkin()); controlPanel.add(btn).size(100, 50); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); gameController.buy(currentPlayer); } }); controlPanel.row(); btn = new TextButton("Discard", getSkin()); controlPanel.add(btn).size(100, 50); btn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); gameController.discard(currentPlayer); } }); controlPanel.row(); }
From source file:com.ahsgaming.valleyofbones.screens.OptionsScreen.java
License:Apache License
@Override public void resize(int width, int height) { super.resize(width, height); //To change body of overridden methods use File | Settings | File Templates. Table table = new Table(getSkin()); table.setFillParent(true);//from w w w .ja va 2s . c o m stage.addActor(table); table.add(new Label("OPTIONS", getSkin(), "medium")).colspan(2).spaceBottom(30); table.row(); table.add(new Label("Name:", getSkin(), "small")).spaceBottom(15); table.add(txtName).space(5).spaceBottom(15).colspan(5).width(205).align(Align.left); table.row(); table.add(new Label("GameJolt Token:", getSkin(), "small")).spaceBottom(15); table.add(txtToken).space(5).spaceBottom(15).colspan(2).width(205).align(Align.left); table.add(btnAuth).space(5).spaceBottom(15); table.add(chkAuthenticated).colspan(2).space(5).spaceBottom(15); table.row(); table.add(new Label("Textures:", getSkin(), "small")).spaceBottom(15); table.add(btnAuto).space(5).spaceBottom(15).size(100, 40); table.add(btnLDPI).space(5).spaceBottom(15).size(100, 40); table.add(btnMDPI).space(5).spaceBottom(15).size(100, 40); table.add(btnHDPI).space(5).spaceBottom(15).size(100, 40); table.add(btnXHDPI).space(5).spaceBottom(15).size(100, 40); table.row(); table.add(new Label("Filter:", getSkin(), "small")).spaceBottom(15); table.add(btnNearest).spaceBottom(15).size(100, 40); table.add(btnLinear).spaceBottom(15).size(100, 40); table.row(); TextButton btnSubmit = new TextButton("SAVE", getSkin()); TextButton btnCancel = new TextButton("CANCEL", getSkin(), "cancel"); table.add(btnCancel).pad(4).size(150, 50).colspan(3); table.add(btnSubmit).pad(4).size(150, 50).colspan(3); table.row(); btnSubmit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); if (txtName.getText().trim().length() > 0) { game.profile.name = txtName.getText().trim(); game.profile.token = txtToken.getText().trim(); game.profile.filter = (bgFilter.getChecked() == btnLinear ? Texture.TextureFilter.Linear : Texture.TextureFilter.Nearest); if (bgScale.getChecked() == btnLDPI) { game.profile.scale = 0.75f; } else if (bgScale.getChecked() == btnMDPI) { game.profile.scale = 1f; } else if (bgScale.getChecked() == btnHDPI) { game.profile.scale = 2f; } else if (bgScale.getChecked() == btnXHDPI) { game.profile.scale = 4f; } else { game.profile.scale = -1; } game.saveProfile(); game.setScreen(game.getMainMenuScreen()); } } }); btnCancel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); game.setScreen(game.getMainMenuScreen()); } }); btnAuth.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); temp.name = txtName.getText().trim(); temp.token = txtToken.getText().trim(); chkAuthenticated.setText(" Authenticating..."); chkAuthenticated.setChecked(false); Auth.authenticate(temp.name, temp.token, new Auth.Callback() { @Override public void result(Object result) { chkAuthenticated.setText(" Looks Good!"); chkAuthenticated.setChecked(true); } @Override public void error(Object error) { if (((Auth.AuthError) error).message.equals("Http Error")) { chkAuthenticated.setText(" Http Error"); } else { chkAuthenticated.setText(" Invalid name/token"); } chkAuthenticated.setChecked(false); } }); } }); }
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);//from ww w . j ava 2 s .c om 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.j av a 2 s. c om*/ 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.ai.tests.utils.scene2d.TabbedPane.java
License:Apache License
private void initialize() { setTouchable(Touchable.enabled);/* ww w . j a va 2 s . c om*/ tabTitleTable = new Table(); tabBodyStack = new Stack(); selectedIndex = -1; // Create 1st row Cell<?> leftCell = add(new Image(style.titleBegin)); Cell<?> midCell = add(tabTitleTable); Cell<?> rightCell = add(new Image(style.titleEnd)); switch (tabTitleAlign) { case Align.left: leftCell.width(((Image) leftCell.getActor()).getWidth()).bottom(); midCell.left(); rightCell.expandX().fillX().bottom(); break; case Align.right: leftCell.expandX().fillX().bottom(); midCell.right(); rightCell.width(((Image) rightCell.getActor()).getWidth()).bottom(); break; case Align.center: leftCell.expandX().fillX().bottom(); midCell.center(); rightCell.expandX().fillX().bottom(); break; default: throw new IllegalArgumentException("TabbedPane align must be one of left, center, right"); } // Create 2nd row row(); Table t = new Table(); t.setBackground(style.bodyBackground); t.add(tabBodyStack); add(t).colspan(3).expand().fill(); }
From source file:com.badlogic.gdx.tests.BulletTestCollection.java
License:Apache License
@Override public void create() { if (app == null) { app = Gdx.app;//ww w. j ava 2 s . 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.bsencan.openchess.view.GameRenderer.java
License:Apache License
private void initUpperUI() { this.upperTextHud = new Table(Assets.skin); this.upperTextHud.add(this.scoreLabel); this.upperTextHud.setTransform(true); this.upperTextHud.setScale(0.5f / this.resetButton.getHeight()); this.scoreLabel.setColor(Color.WHITE); this.scoreLabel.setAlignment(Align.left); this.upperTextHud.align(Align.left); this.upperTextHud.setPosition(0.7f, VIEWPORT_HEIGHT - 0.52f); this.stage.addActor(this.upperTextHud); Table highScoreTable = new Table(Assets.skin); highScoreTable.add(this.highScoreLabel); highScoreTable.setTransform(true);//from w w w . jav a 2 s . c om highScoreTable.setScale(0.5f / this.resetButton.getHeight()); highScoreLabel.setColor(Color.WHITE); highScoreLabel.setAlignment(Align.left); highScoreTable.align(Align.left); highScoreTable.setPosition(VIEWPORT_WIDTH / 2 + 0.7f, VIEWPORT_HEIGHT - 0.52f); stage.addActor(highScoreTable); }
From source file:com.gdx.extension.ui.Console.java
License:Apache License
/** * Add an entry in the console.//from w w w. j a v a 2 s . c o m * * @param entry the entry to add */ public synchronized void addEntry(String entry) { SnapshotArray<Actor> _children = body.getChildren(); if (_children.size >= maxEntries) { _children.first().remove(); } Label _entryLabel = new Label(entry, style.entryStyle); _entryLabel.setAlignment(Align.left); _entryLabel.setWrap(true); body.addActor(_entryLabel); }
From source file:com.gdx.extension.ui.grid.GridSelection.java
License:Apache License
/** * Create a {@link GridSelection} with defined parameters. * /* ww w. j a v a2 s . c om*/ * @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(); } }