private void setFillOverride(Paint fillOverride) {
   if (fillOverride instanceof Color) {
     Color c = (Color) fillOverride;
     progress.setStyle(
         "-fx-background-color: rgba("
             + ((int) (255 * c.getRed()))
             + ","
             + ""
             + ((int) (255 * c.getGreen()))
             + ","
             + ((int) (255 * c.getBlue()))
             + ","
             + ""
             + c.getOpacity()
             + ");");
   } else {
     progress.setStyle(null);
   }
 }
示例#2
2
  public static void message(String msg, StackPane pane) {

    Label warningL = new Label(msg);
    Labels.setLabelStyle(warningL, Custom.TEXT_SIZE_LARGER, true);
    warningL.setTextAlignment(TextAlignment.CENTER);

    StackPane warningPane = new StackPane();
    warningPane.getChildren().add(warningL);
    warningPane.setStyle(Custom.WINDOW_STYLING);
    warningPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100);
    warningPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    warningPane.setBorder(
        new Border(
            new BorderStroke(
                Paint.valueOf("#000000"),
                BorderStrokeStyle.SOLID,
                new CornerRadii(30),
                new BorderWidths(5))));

    pane.getChildren().add(warningPane);

    PauseTransition pause = new PauseTransition(Duration.millis(1500));
    pause.setOnFinished(
        (f) -> {
          pane.getChildren().remove(warningPane);
          goBack();
        });
    pause.play();
  }
示例#3
1
  public static void setPayPane(int amount) {

    message = new Label(Custom.PAY_PTS_MESSAGE);
    Labels.setLabelStyle(message, Custom.TEXT_SIZE_LARGER, true);
    StackPane.setAlignment(message, Pos.CENTER);

    payBtn = new Button(Custom.YES);
    Buttons.setStoreLargerButtons(payBtn, true);
    StackPane.setAlignment(payBtn, Pos.BOTTOM_LEFT);
    payBtn.setOnAction((ae) -> PayPoints.buy(amount));

    backBtn = new Button(Custom.NO);
    Buttons.setStoreLargerButtons(backBtn, true);
    StackPane.setAlignment(backBtn, Pos.BOTTOM_RIGHT);
    backBtn.setOnAction((ae) -> PayPoints.goBack());

    mainPane = new StackPane();
    mainPane.setStyle(Custom.WINDOW_STYLING);
    mainPane.setMinWidth(Custom.SCREEN_WIDTH * 95 / 100);
    mainPane.setMaxWidth(Custom.SCREEN_WIDTH * 95 / 100);
    mainPane.setMinHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    mainPane.setMaxHeight(Custom.SCREEN_HEIGHT * 2 / 5);
    mainPane.setBorder(
        new Border(
            new BorderStroke(
                Paint.valueOf("#000000"),
                BorderStrokeStyle.SOLID,
                new CornerRadii(30),
                new BorderWidths(5))));
    mainPane.getChildren().addAll(message, payBtn, backBtn);
    mainPane.setPadding(new Insets(10, 10, 10, 10));
    StackPane.setAlignment(mainPane, Pos.CENTER);

    backPane = new StackPane();
    backPane.getChildren().add(mainPane);
    backPane.setStyle(Custom.MENU_BACKGROUND);

    getRoot().getChildren().add(backPane);
  }
 private void updateLafDarcula() {
   Platform.runLater(
       () -> {
         final URL engineStyleUrl = getClass().getResource("/style/javaFXBrowserDarcula.css");
         final URL scrollBarStyleUrl =
             getClass().getResource("/style/javaFXBrowserDarculaScrollBar.css");
         myEngine.setUserStyleSheetLocation(engineStyleUrl.toExternalForm());
         myPane.getStylesheets().add(scrollBarStyleUrl.toExternalForm());
         myPane.setStyle("-fx-background-color: #3c3f41");
         myPanel.getScene().getStylesheets().add(engineStyleUrl.toExternalForm());
         myEngine.reload();
       });
 }
示例#5
0
  /** リザルト画面を生成する。 */
  public ResultScreen() {
    // スペースキー押下時にタイトル画面に切り替えるようにする。
    setOnKeyTyped(
        event -> {
          // KeyTyped イベントの場合は KeyCode を得られないので,Character で判定する。
          if (event.getCharacter().equals(" ")) {
            Main.changeScreen(0);
          }
        });
    setFocusTraversable(true);

    // ゲーム情報の最終値を取得する。
    long score = GameContext.getScore();
    long lifeBonus = GameContext.getLifeCount() * Configuration.SCORE_PER_LIFE;
    GameContext.addScore(lifeBonus);
    long totalScore = GameContext.getScore();

    // ランクを計算する。
    String rank;
    if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_S) {
      rank = "S";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_A) {
      rank = "A";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_B) {
      rank = "B";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_C) {
      rank = "C";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_D) {
      rank = "D";
    } else {
      rank = "E";
    }

    // 画面に表示するテキストを生成する。
    Text resultCaptionText = createText("CONGRATULATION!!", 100, Color.GREENYELLOW);
    Text scoreCaptionText = createText("SCORE", 50, Color.GREENYELLOW);
    Text scoreText = createText(Long.toString(score), "monospace", 50, Color.GREENYELLOW);
    Text lifeBonusCaptionText = createText("LIFE BONUS", 50, Color.GREENYELLOW);
    Text lifeBonusText = createText(Long.toString(lifeBonus), "monospace", 50, Color.GREENYELLOW);
    Text totalScoreCaptionText = createText("TOTAL SCORE", 50, Color.GREENYELLOW);
    Text totalScoreText = createText(Long.toString(totalScore), "monospace", 50, Color.GREENYELLOW);
    Text rankCaptionText = createText("RANK", 50, Color.GREENYELLOW);
    Text rankText = createText(rank, 50, Color.GREENYELLOW);

    // 区切り線を生成する。
    VBox[] partitionPanes = new VBox[3];
    IntStream.range(0, partitionPanes.length)
        .forEach(
            i -> {
              partitionPanes[i] = new VBox();
              partitionPanes[i].setPrefHeight(Configuration.PARTITION_HEIGHT);
              partitionPanes[i].setStyle("-fx-background-color: greenyellow;");
            });

    // テキスト,および区切り線をグリッドペインに配置する。
    GridPane gridPane = new GridPane();
    GridPane.setHalignment(resultCaptionText, HPos.CENTER);
    GridPane.setHalignment(scoreText, HPos.RIGHT);
    GridPane.setHalignment(lifeBonusText, HPos.RIGHT);
    GridPane.setHalignment(totalScoreText, HPos.RIGHT);
    GridPane.setHalignment(rankText, HPos.CENTER);
    GridPane.setHgrow(scoreCaptionText, Priority.ALWAYS);
    gridPane.add(resultCaptionText, 0, 0, 2, 1);
    gridPane.add(partitionPanes[0], 0, 1, 2, 1);
    gridPane.add(scoreCaptionText, 0, 2);
    gridPane.add(scoreText, 1, 2);
    gridPane.add(lifeBonusCaptionText, 0, 3);
    gridPane.add(lifeBonusText, 1, 3);
    gridPane.add(partitionPanes[1], 0, 4, 2, 1);
    gridPane.add(totalScoreCaptionText, 0, 5);
    gridPane.add(totalScoreText, 1, 5);
    gridPane.add(rankCaptionText, 0, 6);
    gridPane.add(rankText, 1, 6);
    gridPane.add(partitionPanes[2], 0, 7, 2, 1);

    // グリッドペインをスタックペインに配置する。
    // こうすることで,グリッドペインが画面の中央に配置される。
    StackPane stackPane = new StackPane(new Group(gridPane));
    stackPane.setPrefSize(Configuration.SCREEN_WIDTH, Configuration.SCREEN_HEIGHT);
    stackPane.setStyle("-fx-background-color: black;");

    // 画面にスタックペインを配置する。
    getChildren().add(stackPane);
  }
示例#6
0
  @Override
  public void start(Stage primaryStage) {
    try {
      screen = primaryStage;
      screen.setOnCloseRequest(
          e -> {
            engine.interrupt();
          });

      lives = new SimpleDoubleProperty(1);
      lives.addListener(
          e -> {
            if (lives.get() == 0) {
              engine.interrupt();
              newGame.setText("Start new game");
              changeScene();
            }
          });

      logo = new Image(getClass().getResourceAsStream("logo.png"), 256, 256, true, true);
      logoView = new ImageView(logo);
      menu = new StackPane(logoView);

      livesText = new Text(String.valueOf((int) lives.get()));
      slowDownsText = new Text(String.valueOf(slowDownCount));
      score = new Text("Score");
      scorePoints = new Text(String.valueOf(points));

      livesText.setFill(Color.BEIGE);
      slowDownsText.setFill(Color.BEIGE);
      score.setFill(Color.BEIGE);
      scorePoints.setFill(Color.BEIGE);

      live = new Image(getClass().getResourceAsStream("live.png"));
      slowDown = new Image(getClass().getResourceAsStream("slowdown.png"));

      spotView = new ImageView(new Image(getClass().getResourceAsStream("spot.png")));
      liveView = new ImageView(live);
      slowDownView = new ImageView(slowDown);
      liveCounterView = new ImageView(live);
      slowDownCounterView = new ImageView(slowDown);

      spotView.setVisible(false);
      liveView.setVisible(false);
      slowDownView.setVisible(false);

      spotView.setOnMouseClicked(
          e -> {
            spotView.setVisible(false);
            clicked = true;
            points++;
            if (time > 400) {
              time -= 20;
            }
            scorePoints.setText(String.valueOf(points * 10));
          });

      liveView.setOnMouseClicked(
          e -> {
            liveView.setVisible(false);
            clicked = true;
            points++;
            lives.set(lives.get() + 1);
            livesText.setText(String.valueOf((int) lives.get()));
            scorePoints.setText(String.valueOf(points * 10));
          });

      slowDownView.setOnMouseClicked(
          e -> {
            slowDownView.setVisible(false);
            clicked = true;
            points++;
            slowDownCount++;
            slowDownsText.setText(String.valueOf(slowDownCount));
            scorePoints.setText(String.valueOf(points * 10));
          });

      slowDownCounterView.setOnMouseClicked(
          e -> {
            if (slowDownCount > 0) {
              slowDownCount--;
              slowDownsText.setText(String.valueOf(slowDownCount));
              time += 150;
            }
          });

      Separator sepOne = new Separator(Orientation.VERTICAL);
      sepOne.setOpacity(0.1);

      Separator sepTwo = new Separator(Orientation.VERTICAL);
      sepTwo.setOpacity(0.1);

      HBox header =
          new HBox(
              5,
              liveCounterView,
              livesText,
              sepOne,
              slowDownCounterView,
              slowDownsText,
              sepTwo,
              score,
              scorePoints);
      header.setAlignment(Pos.CENTER_LEFT);
      header.setStyle(
          "-fx-background-color:linear-gradient(#242424 50%, #2D2D2D 75%, #3C3C3C 100%);");
      header.setPadding(new Insets(3, 1, 3, 1));

      playField = new StackPane(spotView, liveView, slowDownView);
      playField.setAlignment(Pos.TOP_LEFT);
      playField.setStyle(
          "-fx-background-color: linear-gradient(#9d9e9d 5%, #6b6a6b 20%, #343534 80%, #242424 100%);");

      root = new BorderPane(playField, header, null, null, null);
      root.setStyle("-fx-border-color: #13BFF8");

      playScene = new Scene(root, 300, 500);

      newGame = new Button("Start");
      newGame.setStyle(
          "-fx-background-color: linear-gradient(TRANSPARENT 50%, #FFFFFF 100%);  -fx-text-fill: #FFFFFF; -fx-min-width: 128px;");
      newGame.setOnMouseEntered(
          e ->
              newGame.setStyle(
                  "-fx-background-color: linear-gradient(TRANSPARENT 10%, #FFFFFF 100%);  -fx-text-fill: #FFFFFF; -fx-min-width: 128px;"));
      newGame.setOnMouseExited(
          e ->
              newGame.setStyle(
                  "-fx-background-color: linear-gradient(TRANSPARENT 50%, #FFFFFF 100%);  -fx-text-fill: #FFFFFF; -fx-min-width: 128px;"));
      newGame.setTranslateY(80);
      newGame.setOnMouseClicked(
          e -> {
            points = 0;
            time = 1500;
            clicked = false;
            slowDownCount = 0;
            lives.set(1);
            livesText.setText(String.valueOf((int) lives.get()));
            screen.setScene(playScene);
            engine = new Engine(this);
            engine.start();
          });
      menu.getChildren().add(newGame);

      menuScene = new Scene(menu, 256, 256);
      menu.setStyle(
          "-fx-background-color: linear-gradient(#9d9e9d 5%, #6b6a6b 20%, #343534 80%, #242424 100%); -fx-border-color: #13BFF8;");

      primaryStage.setScene(menuScene);
      primaryStage.setResizable(false);
      primaryStage.initStyle(StageStyle.UNDECORATED);
      primaryStage.show();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }