List of usage examples for com.badlogic.gdx.scenes.scene2d Group setTransform
public void setTransform(boolean transform)
From source file:com.tumblr.oddlydrawn.nahlc.screens.GameOverScreen.java
License:Apache License
public GameOverScreen(Game g, int level, int score) { game = g;//from w ww. j a v a 2 s . c o m savedStuff = new SavedStuff(); assets = new Assets(); assets.initGameOver(); stage = new Stage(new StretchViewport(Renderer.WIDTH, Renderer.HEIGHT)); skin = new Skin(); savedStuff.loadScores(); savedStuff.setScore(score); skin.add("default", new BitmapFont(Gdx.files.internal("data/fonts/deja.fnt"))); LabelStyle labelStyle = new LabelStyle(); labelStyle.font = skin.getFont("default"); skin.add("default", labelStyle); ButtonStyle buttonStyle = new ButtonStyle(); skin.add("default", buttonStyle); TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.font = skin.getFont("default"); skin.add("default", textButtonStyle); // Background NinePatch image Image boxPatchImage = new Image(assets.getBoxPatch()); boxPatchImage.setSize(Renderer.WIDTH - 40, Renderer.HEIGHT - 5); boxPatchImage.setPosition(20, 2); stage.addActor(boxPatchImage); // Top Score's background NinePatch image Image boxPatchImageTwo = new Image(assets.getBoxPatch()); boxPatchImageTwo.setSize(220, 295); boxPatchImageTwo.setPosition(50, 90); stage.addActor(boxPatchImageTwo); // Single-column table that holds all the things. rootTable = new Table(); rootTable.setFillParent(true); stage.addActor(rootTable); rootTable.debug(); // Three-column table that holds the top scores. topScoreTable = new Table(); topScoreTable.debug(); topScoreTable.columnDefaults(0).width(73); topScoreTable.columnDefaults(1).width(50); topScoreTable.columnDefaults(1).align(Align.center); Label scoreLabel = new Label("Score: " + score, skin); Label topScoresLabel = new Label("Top Scores", skin); Image mainMenuImage = new Image(assets.getMainMenuSprite()); Image newGameImage = new Image(assets.getNewGameSprite()); Button mainMenuButton = new Button(skin); mainMenuButton.add(mainMenuImage); Button newGameButton = new Button(skin); newGameButton.add(newGameImage); Image newRecordImage = new Image(assets.getNewRecordSprite()); Image gameOverImage = new Image(assets.getGameOverSprite()); Image titleImage; if (savedStuff.isPreviousScoreInTopScore()) { titleImage = newRecordImage; } else { titleImage = gameOverImage; } Label[][] allTheScores = new Label[3][11]; // Creates the labels for all the scores, populates them, and adds animations. for (int y = 0; y < 10; y++) { for (int x = 0; x < 3; x++) { switch (x) { case 0: // The labels from 1 - 10, left most to show score rank. if (y == 9) { allTheScores[x][y] = new Label(String.valueOf(y + 1) + ".", skin); } else { // Adds a space, for correct padding to numbers 1-9 (or the array indexes 0-8) allTheScores[x][y] = new Label(" " + String.valueOf(y + 1) + ".", skin); } topScoreTable.add(allTheScores[x][y]); break; case 1: // The labels with the Level associated with each score allTheScores[x][y] = new Label(savedStuff.getLevel(y, x - 1), skin); topScoreTable.add(allTheScores[x][y]); if (savedStuff.isPreviousScoreInTopScore()) { // Adds the drop animation to scores below the score to replace if (y >= savedStuff.getScoreToReplace()) { allTheScores[x][y].addAction(Actions.sequence(Actions.delay(2f), Actions.delay(0.5f), Actions.moveBy(0, -26, 2, Interpolation.bounceOut))); } } break; case 2: // The labels with the Score associated with each rank and level allTheScores[x][y] = new Label(savedStuff.getScore(y, x - 1), skin); topScoreTable.add(allTheScores[x][y]).right(); if (savedStuff.isPreviousScoreInTopScore()) { // Adds the drop animation to scores below the score to replace if (y >= savedStuff.getScoreToReplace()) { allTheScores[x][y].addAction(Actions.sequence(Actions.delay(2f), Actions.delay(0.5f), Actions.moveBy(0, -26, 2, Interpolation.bounceOut))); } } break; default: break; } } topScoreTable.row(); } rootTable.add(titleImage); rootTable.row(); rootTable.add(scoreLabel).expand(); rootTable.row(); rootTable.add(topScoresLabel); rootTable.row(); topScoreTable.setWidth(rootTable.getWidth()); topScoreTable.setTransform(true); rootTable.setTransform(true); rootTable.add(topScoreTable); rootTable.row(); rootTable.add(newGameButton).expand().bottom(); rootTable.row(); rootTable.add(mainMenuButton).expand(); rootTable.padLeft(35f); rootTable.padRight(35f); rootTable.padTop(9f); rootTable.padBottom(9f); newGameButton.toBack(); mainMenuButton.toBack(); // Adds padding to Level and 10th rank strings for correct padding String levelButtonString; int mew = Integer.valueOf(String.valueOf(allTheScores[1][9].getText())); if (mew < 10) { levelButtonString = String.valueOf(allTheScores[1][9].getText()) + " "; } else { levelButtonString = String.valueOf(allTheScores[1][9].getText()); } String previousLevelButtonString; if (level < 10) { previousLevelButtonString = String.valueOf(level + " "); } else { previousLevelButtonString = String.valueOf(level); } String previousScoreString = String.valueOf(score); TextButton previousLevelButton = new TextButton(previousLevelButtonString, skin); TextButton previousScoreButton = new TextButton(previousScoreString, skin); TextButton tenthLevelButton = new TextButton(levelButtonString, skin); TextButton tenthScoreButton = new TextButton(String.valueOf(allTheScores[2][9].getText()), skin); // Pads Button text with spaces for correct alignment tenthLevelButton.setText(fillStringWithSpaces(String.valueOf(tenthLevelButton.getText()))); previousLevelButton.setText(fillStringWithSpaces(previousLevelButtonString)); stage.addActor(tenthLevelButton); stage.addActor(tenthScoreButton); // Groups to link the scores and levels for 10th-rank scores and the score just obtained // Needed to apply transforms to buttons since transforming text isn't possible, I think. Group group = new Group(); group.addActor(tenthScoreButton); group.addActor(tenthLevelButton); Group groupPrevious = new Group(); groupPrevious.addActor(previousLevelButton); groupPrevious.addActor(previousScoreButton); // Modifies score buttons positions for correct alignment with the rest of the table tenthScoreButton.setPosition(144 - subPosFromLength(tenthScoreButton.getText().length()), 00); previousScoreButton.setPosition(144 - subPosFromLength(previousScoreString.length()), 00); tenthScoreButton.align(Align.left); previousScoreButton.align(Align.left); tenthLevelButton.setTransform(true); tenthScoreButton.setTransform(true); stage.addActor(group); group.setPosition(105, 97); allTheScores[1][9].setVisible(false); allTheScores[2][9].setVisible(false); group.setTransform(true); // Adds animation for drop and bounce then rotate and drop to 10th rank score if (savedStuff.isPreviousScoreInTopScore()) { group.setOrigin(group.getX() + group.getWidth() + 50, 10); group.addAction(Actions.sequence(Actions.delay(2f), Actions.delay(0.5f), Actions.moveBy(0, -26, 2, Interpolation.bounceOut), Actions.delay(0.1f), Actions.rotateBy(90f, 2f, Interpolation.bounceOut), Actions.delay(0.1f), Actions.moveBy(0, -120, 2, Interpolation.bounceOut))); } // Adds spaces to first score in top score table to have the same column width regardless of score size allTheScores[2][0].setText(fillCSWithSpaces(allTheScores[2][0].getText())); mainMenuButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { dispose(); game.setScreen(new MainMenuScreen(game)); } }); newGameButton.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { dispose(); game.setScreen(new GameScreen(game)); } }); // Sets correct vertical position for score just obtained groupPrevious.setPosition(group.getX(), group.getY() + getVerticalPosSub(savedStuff.getScoreToReplace())); groupPrevious.setTransform(true); // Score is now in position, this makes it invisible groupPrevious.addAction(Actions.fadeOut(0.1f)); // Fades the score in after the bottom-most score rotates and drops if (savedStuff.isPreviousScoreInTopScore()) { groupPrevious.addAction(Actions.sequence(Actions.delay(7.5f), Actions.fadeIn(1f))); } stage.addActor(groupPrevious); savedStuff.setSavedGameExists(false); savedStuff.savePreferences(); savedStuff.updateLevelAndScore(level, score); try { savedStuff.saveScoresToFile(); } catch (RuntimeException ex) { Gdx.app.log("ERROR NAHLC", ex.getMessage()); ex.printStackTrace(); } catch (Exception e) { Gdx.app.log("ERROR NAHLC", e.getMessage()); e.printStackTrace(); } Gdx.app.log("NAHLC", "leaving create()"); }
From source file:com.vlaaad.dice.game.world.controllers.ViewController.java
License:Open Source License
private void initLayer(Group layer) { layer.setSize(world.width * CELL_SIZE, world.height * CELL_SIZE); layer.setTransform(false); }
From source file:com.vlaaad.dice.game.world.view.StepDetectorSubView.java
License:Open Source License
private void initGlow(Tile a, Tile b, Group group) { move(a);/*from www. ja v a 2 s . c om*/ move(b); a.addAction(forever(sequence(alpha(0, 1), alpha(1, 1)))); b.getColor().a = 0f; b.addAction(forever(sequence(alpha(1, 1), alpha(0, 1)))); group.addActor(a); group.addActor(b); group.setTransform(false); }
From source file:com.vlaaad.dice.game.world.view.visualizers.DropVisualizer.java
License:Open Source License
@Override public IFuture<Void> visualize(DroppedItem drop) { final Future<Void> future = new Future<Void>(); Group group = new Group(); Tile image = new Tile("item/" + drop.item.name); Label counter = new Label(String.valueOf(drop.count), Config.skin); counter.setSize(image.getWidth(), image.getHeight()); counter.setAlignment(Align.right | Align.bottom); group.addActor(image);// w w w .j av a 2s. c o m group.addActor(counter); group.setTransform(false); visualizer.viewController.notificationLayer.addActor(group); group.setPosition(drop.target.getX() * ViewController.CELL_SIZE, drop.target.getY() * ViewController.CELL_SIZE); group.addAction(Actions.parallel(Actions.moveBy(0, 30, 1f, Interpolation.fade), Actions.alpha(0, 1f, Interpolation.fade), Actions.delay(0.4f, Actions.run(new Runnable() { @Override public void run() { future.happen(); } })))); return future; }
From source file:com.vlaaad.dice.ui.windows.PurchaseWindow.java
License:Open Source License
private Cell add(Table items, final ItemPurchaseInfo info) { Button button = new Button(Config.skin, "purchase-item"); SoundHelper.initButton(button);//from w w w. j ava 2 s .co m button.align(Align.left); Table description = new Table(Config.skin); description.align(Align.left); description.add(new LocLabel("ui-purchase-item-" + info.itemName + "-" + info.count + "-name", NAME_COLOR)) .align(Align.left).padTop(-1).row(); description .add(new LocLabel("ui-purchase-item-" + info.itemName + "-" + info.count + "-count", COUNT_COLOR)) .align(Align.left).padTop(-4); button.add(new Image(Config.skin, "ui-purchase-item-" + info.itemName + "-" + info.count)).padLeft(2); button.add(description).pad(2).padLeft(4); if (info.discount != 0) { Group discount = new Group(); discount.setTouchable(Touchable.disabled); discount.setTransform(false); discount.addActor(new Image(Config.skin, "ui-discount-icon")); Label label = new Label(info.discount + "%", Config.skin); label.setPosition(7, 5); discount.addActor(label); button.addActor(discount); discount.setPosition(115, 5); } button.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { chosen = info; hide(); } }); return items.add(button).width(140); }
From source file:es.eucm.ead.engine.components.assets.ReferenceComponent.java
License:Open Source License
public void setGroup(Group group) { this.group = group; group.setTransform(false); }
From source file:net.mwplay.cocostudio.ui.parser.GroupParser.java
License:Apache License
/** * ?group,?Group?Widget???//from w w w .j a va2s.c o m */ public Group groupChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) { Group group = (Group) actor; // Group ?,? actor.setTouchable(widget.isTouchEnable() ? Touchable.enabled : Touchable.childrenOnly); // Transform true ???. // group.setTransform(true); if (widget.getScale() != null || widget.getRotation() != 0) { group.setTransform(true); } for (ObjectData childrenWidget : widget.getChildren()) { Actor childrenActor = editor.parseWidget(group, childrenWidget); if (childrenActor == null) { continue; } group.addActor(childrenActor); } sort(widget, group); return group; }