Exemplo n.º 1
0
  public AotHudGameOver(Skin sk) {
    _skin = sk;
    Label gameover = new Label("GAME OVER", _skin.get("JUNEBUG_32", LabelStyle.class));
    _retry = new Label(">> RETRY <<", _skin.get("JUNEBUG_16", LabelStyle.class));
    _lvlselect = new Label(">> LEVEL SELECTION <<", _skin.get("JUNEBUG_16", LabelStyle.class));

    _retry.setPosition(0, 0);
    _lvlselect.setPosition(_retry.getWidth() + 100, 0);

    this.setWidth(_retry.getWidth() + _lvlselect.getWidth() + 100);

    gameover.setPosition((this.getWidth() - gameover.getWidth()) / 2, _retry.getHeight() + 100);

    this.setHeight(_retry.getHeight() + gameover.getHeight() + 100);

    addActor(gameover);
    addActor(_retry);
    addActor(_lvlselect);

    this.setPosition(
        (AbstractScreen.GAME_VIEWPORT_WIDTH - this.getWidth()) / 2,
        (AbstractScreen.MENU_VIEWPORT_HEIGHT - this.getHeight()) / 2 - 100);

    _lvlselect.addListener(this);
    _retry.addListener(this);
  }
Exemplo n.º 2
0
 /** returns the title and positions it in the default position */
 public Label getTitle() {
   Label title = new Label(Constants.TITLE, new LabelStyle(new BitmapFont(), Color.RED));
   title.setFontScale(2);
   title.setX(Gdx.graphics.getWidth() / 2 - title.getWidth());
   float offsetTitle = Gdx.graphics.getHeight() * 0.1f;
   title.setY(Gdx.graphics.getHeight() / 2 + offsetTitle);
   return title;
 }
Exemplo n.º 3
0
 public void showNotif(String text) {
   notifTxt.remove();
   notifTxt.setText(text);
   notifTxt.setPosition(512 - notifTxt.getWidth() / 2, 300 - notifTxt.getHeight() / 2);
   notifTxt.setAlignment(Align.center);
   GdxGame.ui_stage1.addActor(notifTxt);
   notifTxt.clearActions();
   notifTxt.addAction(sequence(alpha(1f), delay(1f), fadeOut(1f), removeActor()));
 }
Exemplo n.º 4
0
  public LabelText(String s, float x, float y) {
    labelStyle = new Label.LabelStyle();
    labelStyle.font = Fonts.GOST_28;
    levNumLabel = new Label(s, labelStyle);
    levNumLabel.setPosition(x / 2 - levNumLabel.getWidth() / 2, y - levNumLabel.getHeight() - 10);
    setOrigin(x / 2, y - levNumLabel.getHeight() / 2 - 10);

    addActor(levNumLabel);
  }
Exemplo n.º 5
0
 public void addScore() {
   LabelStyle style = new LabelStyle();
   style.font =
       new BitmapFont(
           Gdx.files.internal("data/flappyfont.fnt"),
           Gdx.files.internal("data/flappyfont.png"),
           false);
   labelScore = new Label("0", style);
   labelScore.setPosition(
       Flappybird.VIEWPORT.x / 2 - labelScore.getWidth() / 2,
       Flappybird.VIEWPORT.y - labelScore.getHeight());
   stage.addActor(labelScore);
 }
  @Override
  public void create(Object... args) {
    super.create(args);

    Label versionLabel =
        FontManager.Default.makeLabel(
            String.format(
                "v%s (%s, %s)",
                TowerConsts.VERSION,
                TowerConsts.GIT_SHA.substring(0, 8),
                TowerGameService.getDeviceOSMarketName()));
    versionLabel.setColor(Color.LIGHT_GRAY);
    versionLabel.setX(getStage().getWidth() - versionLabel.getWidth() - 5);
    versionLabel.setY(getStage().getHeight() - versionLabel.getHeight() - 5);
    addActor(versionLabel);
  }
Exemplo n.º 7
0
  /**
   * Create a countdown in the screen lasting for the amount of seconds given. When the countdown
   * reaches 0, the code provided in the runnable will be executed as a callback.
   *
   * @param seconds how many seconds should the countdown be displayed.
   */
  private void countdown(final int seconds, final Runnable after) {
    // Since this is a recursive function, avoid the case where you pass
    // a number of seconds that might trigger an infinite loop.
    if (seconds <= 0) {
      return;
    }

    // Create the label that will contain this number
    String number = Integer.toString(seconds);
    final Label label = new Label(number, game.getSkin(), "monospace");
    label.setFontScale(5f);
    label.setSize(150, 150);
    label.setAlignment(Align.center);
    label.setPosition(
        (getStage().getWidth() - label.getWidth()) / 2,
        (getStage().getHeight() - label.getHeight()) / 2);

    // Add the label to the stage and play a sound to notify the user.
    getStage().addActor(label);
    game.player.playSound(SoundCode.SELECT);

    label.addAction(
        Actions.sequence(
            Actions.parallel(Actions.moveBy(0, 80, 1f)),

            // After the animation, decide. If the countdown hasn't finished
            // yet, run another countdown with 1 second less.
            Actions.run(
                new Runnable() {
                  @Override
                  public void run() {
                    label.remove();
                    if (seconds > 1) {
                      countdown(seconds - 1, after);
                    } else {
                      after.run();
                    }
                  }
                })));
  }
Exemplo n.º 8
0
  private void showPartialScore(int score, Bounds bounds, boolean special) {
    // Calculate the center of the region.
    BallActor bottomLeftBall = board.getBall(bounds.minX, bounds.minY);
    BallActor upperRightBall = board.getBall(bounds.maxX, bounds.maxY);

    float minX = bottomLeftBall.getX();
    float maxX = upperRightBall.getX() + upperRightBall.getWidth();
    float minY = bottomLeftBall.getY();
    float maxY = upperRightBall.getY() + upperRightBall.getHeight();
    float centerX = (minX + maxX) / 2;
    float centerY = (minY + maxY) / 2;

    Label label = new Label("+" + score, game.getSkin(), "monospace");
    label.setFontScale(5f);
    label.setSize(140, 70);
    label.setAlignment(Align.center);
    label.setPosition(centerX - label.getWidth() / 2, centerY - label.getHeight() / 2);
    label.addAction(Actions.sequence(Actions.moveBy(0, 80, 0.5f), Actions.removeActor()));
    getStage().addActor(label);

    if (special) {
      label.setColor(Color.CYAN);
    }
  }
Exemplo n.º 9
0
  public void initView() {
    clear();
    float currPos = 0;
    for (int i = 0; i < tabs.size(); i++) {
      boolean isSelected = false;
      if (i == selectedTabIndex) isSelected = true;
      String imgName = "tab";
      if (isSelected) {
        imgName = "tabS";
      }
      Image img = new Image(s.textureManager.getEditorAsset(imgName));
      img.setX(currPos);
      img.setY(0);

      Label lbl = new Label(tabs.get(i), s.textureManager.editorSkin);
      lbl.setX(currPos + 6);
      lbl.setY(2);
      lbl.setTouchable(Touchable.disabled);

      img.setScaleX(lbl.getWidth() + 12);
      currPos += lbl.getWidth() + 12;

      addActor(img);
      addActor(lbl);

      Image sep = new Image(s.textureManager.getEditorAsset("tabSep"));
      sep.setX(img.getX() + img.getScaleX());
      addActor(sep);
      currPos += 1;

      if (isSelected) {
        lbl.setColor(1, 1, 1, 1);
      } else {
        lbl.setColor(1, 1, 1, 0.65f);
      }

      final int currIndex = i;

      img.addListener(
          new ClickListener() {
            public void clicked(InputEvent event, float x, float y) {
              selectedTabIndex = currIndex;
              initView();
              if (tabEventListener != null) {
                tabEventListener.tabOpened(currIndex);
              }
            }
          });

      setHeight(img.getHeight());
    }

    float currWidth = currPos;
    if (getWidth() > currWidth) {
      float diff = getWidth() - currWidth;
      Image rest = new Image(s.textureManager.getEditorAsset("tab"));
      rest.setX(currPos);
      rest.setScaleX(diff);
      addActor(rest);
    }
  }
Exemplo n.º 10
0
  public WinnerScreen(ArrayList<Integer> playerPositions, Game game, Client client, Server server) {
    super(game, client, server);

    // Set input and viewpoint
    stage = new Stage(new StretchViewport(Constants.SCREENWIDTH, Constants.SCREENHEIGHT));
    Gdx.input.setInputProcessor(stage);

    // Unhides the cursor
    Gdx.input.setCursorCatched(false);

    this.playerPositions = playerPositions;

    // Set background
    rootTable.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.hostBackground)));
    rootTable.setFillParent(true);
    stage.addActor(rootTable);

    // Initialise Font
    FreeTypeFontGenerator.FreeTypeFontParameter fontOptions =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    fontOptions.size = 11;
    BitmapFont font = TextureManager.menuFont.generateFont(fontOptions);

    /** ------------------------LABEL STYLE------------------------* */
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    fontOptions.size = 60;
    labelStyle.font = TextureManager.menuFont.generateFont(fontOptions);
    labelStyle.fontColor = Color.GOLD;

    /** ------------------------PLAYER DISPLAY WIDGET------------------------* */
    // Table options
    Table table = new Table();
    table.setFillParent(true);

    // P1 spawn field
    p1Field = new Container();
    p1Field.background(new TextureRegionDrawable(TextureManager.p1WalkingDownAnim.getKeyFrame(0)));
    table.add(p1Field).width(64).height(64);

    // P2 spawn field
    p2Field = new Container();
    p2Field.setVisible(false);
    p2Field.background(new TextureRegionDrawable(TextureManager.p2WalkingDownAnim.getKeyFrame(0)));
    table.add(p2Field).width(64).height(64).padLeft(96);

    // P3 spawn field
    p3Field = new Container();
    p3Field.setVisible(false);
    p3Field.background(new TextureRegionDrawable(TextureManager.p3WalkingDownAnim.getKeyFrame(0)));
    table.add(p3Field).width(64).height(64).padLeft(96);

    // P4 spawn field
    p4Field = new Container();
    p4Field.setVisible(false);
    p4Field.background(new TextureRegionDrawable(TextureManager.p4WalkingDownAnim.getKeyFrame(0)));
    table.add(p4Field).width(64).height(64).padLeft(96);

    // Stage & group options
    joinedPlayerGroup.addActor(table);
    joinedPlayerGroup.setPosition(443, 150);
    stage.addActor(joinedPlayerGroup);

    /** ------------------------PLAYER HIGHLIGHT WIDGET------------------------* */
    // Table options
    Table table2 = new Table();
    table2.setFillParent(true);

    // P1 spawn field
    p1FieldHighlight = new Container();
    p1FieldHighlight.setVisible(false);
    p1FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p1FieldHighlight).width(80).height(77);

    // P2 spawn field
    p2FieldHighlight = new Container();
    p2FieldHighlight.setVisible(false);
    p2FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p2FieldHighlight).width(80).height(77).padLeft(80);

    // P3 spawn field
    p3FieldHighlight = new Container();
    p3FieldHighlight.setVisible(false);
    p3FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p3FieldHighlight).width(80).height(77).padLeft(80);

    // P4 spawn field
    p4FieldHighlight = new Container();
    p4FieldHighlight.setVisible(false);
    p4FieldHighlight.background(
        new TextureRegionDrawable(new TextureRegion(TextureManager.playerMarker)));
    table2.add(p4FieldHighlight).width(80).height(77).padLeft(80);

    // Stage & group options
    playerhighlightWidget.addActor(table2);
    playerhighlightWidget.setPosition(442, 152);
    stage.addActor(playerhighlightWidget);

    /** ------------------------LABELS------------------------* */

    // Titel
    titel = new Label("", labelStyle);
    titel.setAlignment(Align.center);
    titel.setPosition((Constants.SCREENWIDTH - titel.getWidth()) / 2 + 50, 385);
    stage.addActor(titel);

    // If you are the winner
    if (Constants.PLAYERID == playerPositions.get(playerPositions.size() - 1)) {
      titel.setText("YOU WON!");
      isWinner = true;
    } else {
      isWinner = false;
      titel.setText("YOU LOOSE!");
      titel.setColor(Color.RED);
    }

    if (-1 == playerPositions.get(playerPositions.size() - 1)) {
      titel.setText("DRAW!");
      titel.setColor(Color.DARK_GRAY);
      isWinner = false;
    }

    Table positionTable = new Table();
    positionTable.setFillParent(true);

    p1Position = new Label("", labelStyle);
    p1Position.setAlignment(Align.center);

    p2Position = new Label("", labelStyle);
    p2Position.setAlignment(Align.center);

    p3Position = new Label("", labelStyle);
    p3Position.setAlignment(Align.center);

    p4Position = new Label("", labelStyle);
    p4Position.setAlignment(Align.center);

    positionTable.add(p1Position).width(64).height(64);
    positionTable.add(p2Position).width(64).height(64).padLeft(96);
    positionTable.add(p3Position).width(64).height(64).padLeft(96);
    positionTable.add(p4Position).width(64).height(64).padLeft(96);

    positionPlayerWidget.addActor(positionTable);
    positionPlayerWidget.setPosition(443, 230);
    stage.addActor(positionPlayerWidget);

    /** ------------------------MUSIC------------------------* */
    if (isWinner == false) {
      AudioManager.setCurrentMusic(AudioManager.getLooserMusic());
      AudioManager.getCurrentMusic().setLooping(true);
      AudioManager.getCurrentMusic().play();
      AudioManager.getCurrentMusic().setVolume(AudioManager.getMusicVolume() * 4);
    } else {
      AudioManager.setCurrentMusic(AudioManager.getWinnerMusic());
      AudioManager.getCurrentMusic().setLooping(true);
      AudioManager.getCurrentMusic().play();
      AudioManager.getCurrentMusic().setVolume(AudioManager.getMusicVolume() * 6);
    }

    /** ------------------------BUTTONS------------------------* */
    TextButton.TextButtonStyle textButtonStyleBack = new TextButton.TextButtonStyle();
    textButtonStyleBack.font = font;
    textButtonStyleBack.up = backSkin.getDrawable("button_up");
    textButtonStyleBack.down = backSkin.getDrawable("button_down");
    textButtonStyleBack.over = backSkin.getDrawable("button_checked");

    // Back button
    backButton = new TextButton("", textButtonStyleBack);
    backButton.setPosition(0, Constants.SCREENHEIGHT - backButton.getHeight() + 7);
    stage.addActor(backButton);

    renderPlayers();

    // Add click listener --> Back button
    backButton.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            // Add click musik
            AudioManager.playClickSound();

            // Wait till sound is done
            try {
              Thread.sleep(100);

            } catch (InterruptedException ex) {

            }

            if (isWinner) {
              AudioManager.getCurrentMusic().stop();
            } else {
              AudioManager.getCurrentMusic().stop();
            }

            server.stopServer();
            game.setScreen(new MenuScreen(game, client, server));
          }
        });
  }
Exemplo n.º 11
0
  @Override
  public void show() {
    // Creates an stage that contains all the GUI elements
    stage = new Stage();
    stage.clear();
    Gdx.input.setInputProcessor(stage);

    // Title label
    font100orange = new BitmapFont(Gdx.files.internal("fonts/prehistorik100orange.fnt"));
    titleLabel = new Label(this.title, new LabelStyle(font100orange, Color.WHITE));
    titleLabel.setPosition(
        Gdx.graphics.getWidth() / 2.0f - titleLabel.getWidth() / 2,
        7.1f * Gdx.graphics.getHeight() / 9.0f);

    // Textbox label
    white30boldFont = new BitmapFont(Gdx.files.internal("fonts/white30bold.fnt"));
    label1 = new Label("IP adress of game creator:", new LabelStyle(white30boldFont, Color.WHITE));
    label1.setPosition(
        Gdx.graphics.getWidth() / 2.0f - label1.getWidth() / 2,
        6 * Gdx.graphics.getHeight() / 9.0f);

    // Username
    Label usernameLabel = ScreenUtils.createLabel("Username:"******"", 0, 0);
    usernameInput.setPosition(
        Gdx.graphics.getWidth() / 2f - usernameInput.getWidth() / 2f,
        3 * Gdx.graphics.getHeight() / 9.0f);

    // Atlas of the GUI
    atlas = new TextureAtlas("gui/gui.pack");
    skin = new Skin(atlas);

    // Buttons
    font60 = new BitmapFont(Gdx.files.internal("fonts/prehistorik60black.fnt"), false);
    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = skin.getDrawable("button1");
    buttonStyle.over = skin.getDrawable("button1-over");
    buttonStyle.down = skin.getDrawable("button1-down");
    buttonStyle.font = font60;

    joinButton = new TextButton("Join Game", buttonStyle);
    joinButton.setHeight(100f);
    joinButton.setWidth(500f);
    joinButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        1.5f * Gdx.graphics.getHeight() / 9.0f);

    menuButton = new TextButton("Main Menu", buttonStyle);
    menuButton.setHeight(100f);
    menuButton.setWidth(500f);
    menuButton.setPosition(
        Gdx.graphics.getWidth() / 2.0f - joinButton.getWidth() / 2,
        0f * Gdx.graphics.getHeight() / 9.0f);

    // TextField
    white36nonoFont = new BitmapFont(Gdx.files.internal("fonts/white36mono.fnt"));
    TextFieldStyle tfs = new TextFieldStyle();
    tfs.font = white36nonoFont;
    tfs.cursor = skin.getDrawable("cursor");
    tfs.background = skin.getDrawable("textField");
    tfs.fontColor = Color.WHITE;
    inputAddress = new TextField("localhost", tfs);
    inputAddress.setHeight(50);
    inputAddress.setWidth(300);
    inputAddress.setPosition(
        Gdx.graphics.getWidth() / 2.0f - inputAddress.getWidth() / 2,
        5 * Gdx.graphics.getHeight() / 9.0f);

    // add actors
    stage.addActor(joinButton);
    stage.addActor(menuButton);
    stage.addActor(inputAddress);
    stage.addActor(titleLabel);
    stage.addActor(usernameLabel);
    stage.addActor(usernameInput);
    stage.addActor(titleLabel);
    stage.addActor(label1);

    joinButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            System.out.println(inputAddress.getText());

            GameScreen.createInstance(game, false, inputAddress.getText(), usernameInput.getText());
            game.setScreen(GameScreen.getInstance());
            //						game.initInputListeners();

          }
        });

    menuButton.addListener(
        new ChangeListener() {

          @Override
          public void changed(ChangeEvent event, Actor actor) {
            game.setScreen(new MenuScreen(game));
          }
        });
  }
Exemplo n.º 12
0
  @Override
  public void show() {
    imgNinja = new Texture(Gdx.files.internal("Ninja-Shadow.png"));
    imgNinja.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    FreeTypeFontGenerator generator =
        new FreeTypeFontGenerator(Gdx.files.internal("lastninja.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter =
        new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.genMipMaps = true;
    parameter.minFilter = Texture.TextureFilter.Linear.MipMapLinearNearest;
    parameter.magFilter = Texture.TextureFilter.Linear;
    parameter.size = 26;
    final BitmapFont font = generator.generateFont(parameter);

    startLabel = new Label("Start Game", new Label.LabelStyle(font, Color.BLACK));
    startLabel.setPosition(500, 300);
    startLabel.setTouchable(Touchable.enabled);
    startLabel.setBounds(500, 300, startLabel.getWidth(), startLabel.getHeight());
    startLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new PlayScreen(game));
            dispose();
          }
        });

    instructionLabel = new Label("Instructions", new Label.LabelStyle(font, Color.BLACK));
    instructionLabel.setPosition(500, 250);
    instructionLabel.setTouchable(Touchable.enabled);
    instructionLabel.setBounds(500, 250, instructionLabel.getWidth(), instructionLabel.getHeight());
    instructionLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new InstructionScreen(game));
            dispose();
          }
        });

    aboutLabel = new Label("About", new Label.LabelStyle(font, Color.BLACK));
    aboutLabel.setPosition(500, 200);
    aboutLabel.setTouchable(Touchable.enabled);
    aboutLabel.setBounds(500, 200, aboutLabel.getWidth(), aboutLabel.getHeight());
    aboutLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new AboutScreen(game));
            dispose();
          }
        });
    quitLabel = new Label("Quit", new Label.LabelStyle(font, Color.BLACK));
    quitLabel.setPosition(500, 150);
    quitLabel.setTouchable(Touchable.enabled);
    quitLabel.setBounds(500, 150, quitLabel.getWidth(), quitLabel.getHeight());
    quitLabel.addListener(
        new ClickListener() {
          @Override
          public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
          }
        });
    stage.addActor(startLabel);
    stage.addActor(instructionLabel);
    stage.addActor(aboutLabel);
    stage.addActor(quitLabel);
  }
Exemplo n.º 13
0
  @Override
  public void onSelectionSucceeded(final List<BallActor> selection) {
    // Extract the data from the selection.
    List<Ball> balls = new ArrayList<>();
    for (BallActor selectedBall : selection) balls.add(selectedBall.getBall());
    final Bounds bounds = Bounds.fromBallList(balls);

    // Change the colors of the selected region.
    board.addAction(
        Actions.sequence(
            board.hideRegion(bounds),
            Actions.run(
                new Runnable() {
                  @Override
                  public void run() {
                    for (BallActor selectedBall : selection) {
                      selectedBall.setColor(Color.WHITE);
                    }
                    generate(bounds);
                    // Reset the cheat
                    game.getState().setCheatSeen(false);
                    game.getState().setWiggledBounds(null);
                  }
                })));

    // Give some score to the user.
    ScoreCalculator calculator = new ScoreCalculator(game.getState().getBoard(), bounds);
    int givenScore = calculator.calculate();
    game.getState().addScore(givenScore);
    score.giveScore(givenScore);

    // Put information about this combination in the stats.
    int rows = bounds.maxY - bounds.minY + 1;
    int cols = bounds.maxX - bounds.minX + 1;
    String size = Math.max(rows, cols) + "x" + Math.min(rows, cols);
    game.statistics.getSizesData().incrementValue(size);

    BallColor color = board.getBall(bounds.minX, bounds.minY).getBall().getColor();
    game.statistics.getColorData().incrementValue(color.toString().toLowerCase());
    game.statistics.getTotalData().incrementValue("balls", rows * cols);
    game.statistics.getTotalData().incrementValue("combinations");

    // Now, display the score to the user. If the combination is a
    // PERFECT combination, just display PERFECT.
    int boardSize = game.getState().getBoard().getSize() - 1;
    if (bounds.equals(new Bounds(0, 0, boardSize, boardSize))) {
      // Give score
      Label label = new Label("PERFECT", game.getSkin(), "monospace");
      label.setX((getStage().getViewport().getWorldWidth() - label.getWidth()) / 2);
      label.setY((getStage().getViewport().getWorldHeight() - label.getHeight()) / 2);
      label.setFontScale(3);
      label.setAlignment(Align.center);
      label.addAction(Actions.sequence(Actions.moveBy(0, 80, 0.5f), Actions.removeActor()));
      getStage().addActor(label);
      game.player.playSound(SoundCode.PERFECT);

      // Give time
      float givenTime = Constants.SECONDS - timer.getSeconds();
      timer.giveTime(givenTime, 4f);
    } else {
      // Was special?
      boolean special = givenScore != rows * cols;
      // Give score
      showPartialScore(givenScore, bounds, special);
      game.player.playSound(SoundCode.SUCCESS);

      // Give time
      float givenTime = 4f;
      timer.giveTime(givenTime, 0.25f);
    }
  }
Exemplo n.º 14
0
  @Override
  public void create() {

    //		Gdx.gl.glClearColor(
    //			background.rgb.getRed() / 255f,
    //			background.rgb.getGreen() / 255f,
    //			background.rgb.getBlue() / 255f,
    //			background.rgb.getAlpha() / 255f);
    //		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    //		Gdx.graphics.setContinuousRendering(false);
    //		Gdx.graphics.requestRendering();

    cam = new OrthographicCamera();
    batch = new SpriteBatch();

    stage = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    input = new TextField("", skin);

    // can't use Table here since it will conflict with the Swing Table toolkit
    // this is why static is shit -.-
    labelInput = new Label("Sample Text:", skin);
    labelScale = new Label("Scale:", skin);
    scaleAmt = new Label("1.0", skin);

    labelInput.setHeight(input.getHeight());
    labelInput.setPosition(10, Gdx.graphics.getHeight() - labelInput.getHeight() - 5);
    input.setPosition(
        labelInput.getX() + labelInput.getWidth() + 10,
        Gdx.graphics.getHeight() - input.getHeight() - 5);

    scaleSlider = new Slider(0, 3, 0.05f, false, skin);
    scaleSlider.setSnapToValues(new float[] {0.0f, 0.5f, 1.0f}, 0.05f);

    scaleSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent arg0, Actor arg1) {
            scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));
          }
        });
    scaleSlider.setValue(1.0f);
    scaleAmt.setText(String.format("%.2f", scaleSlider.getValue()));

    linearFiltering = new ToggleBox("Linear Filtering", skin);
    linearFiltering.addListener(
        new ClickListener() {
          public void clicked(InputEvent ev, float x, float y) {
            updateFiltering();
          }
        });

    scaleAmt.setHeight(scaleSlider.getHeight());
    labelScale.setHeight(scaleSlider.getHeight());

    labelScale.setPosition(
        input.getX() - 10 - labelScale.getWidth(), labelInput.getY() - labelInput.getHeight() - 5);
    scaleSlider.setPosition(input.getX(), input.getY() - input.getHeight() - 5);
    scaleAmt.setPosition(scaleSlider.getX() + scaleSlider.getWidth() + 5, scaleSlider.getY());

    linearFiltering.setPosition(input.getX(), scaleSlider.getY() - scaleSlider.getHeight() - 10);

    Gdx.input.setInputProcessor(stage);
    stage.addActor(labelInput);
    stage.addActor(input);
    stage.addActor(labelScale);
    stage.addActor(scaleSlider);
    stage.addActor(scaleAmt);
    stage.addActor(linearFiltering);

    myButton = new TextButton("Blah", skin);
  }