Beispiel #1
0
  public Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(140, 140);
    root.setMinSize(Pane.USE_PREF_SIZE, Pane.USE_PREF_SIZE);
    root.setMaxSize(Pane.USE_PREF_SIZE, Pane.USE_PREF_SIZE);
    // create rectangle
    Rectangle rect = new Rectangle(20, 20, 100, 100);
    rect.setArcHeight(20);
    rect.setArcWidth(20);
    rect.setFill(Color.ORANGE);
    root.getChildren().add(rect);

    rotateTransition = new RotateTransition(Duration.seconds(4), rect);
    rotateTransition.setFromAngle(0);
    rotateTransition.setToAngle(720);
    rotateTransition.setCycleCount(Timeline.INDEFINITE);
    rotateTransition.setAutoReverse(true);

    return root;
  }
Beispiel #2
0
  public void animazione(int lancioCorrente, boolean flag) {
    mediaPlayer = new MediaPlayer(media);
    mediaPlayer.play();

    setPrimo((int) ((Math.random() * 6) + 1));
    RotateTransition rt1 = new RotateTransition(Duration.millis(60), imageViewUno);

    rt1.setFromAngle(0.0);
    rt1.setToAngle(360.0);
    rt1.setCycleCount(2);
    rt1.setAutoReverse(true);
    rt1.setAxis(Rotate.X_AXIS);

    rt1.play();

    rt1.setOnFinished(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {

            setPrimo((int) ((Math.random() * 6) + 1));
            RotateTransition rt2 = new RotateTransition(Duration.millis(durata), imageViewUno);

            rt2.setFromAngle(0.0);
            rt2.setToAngle(360.0);
            rt2.setCycleCount(2);
            rt2.setAutoReverse(true);
            rt2.setAxis(Rotate.X_AXIS);

            rt2.play();

            rt2.setOnFinished(
                new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent event) {

                    setPrimo((int) ((Math.random() * 6) + 1));
                    RotateTransition rt3 =
                        new RotateTransition(Duration.millis(durata), imageViewUno);

                    rt3.setFromAngle(0.0);
                    rt3.setToAngle(360.0);
                    rt3.setCycleCount(2);
                    rt3.setAutoReverse(true);
                    rt3.setAxis(Rotate.Y_AXIS);

                    rt3.play();

                    rt3.setOnFinished(
                        new EventHandler<ActionEvent>() {

                          @Override
                          public void handle(ActionEvent event) {

                            setPrimo((int) ((Math.random() * 6) + 1));
                            RotateTransition rt4 =
                                new RotateTransition(Duration.millis(durata), imageViewUno);

                            rt4.setFromAngle(0.0);
                            rt4.setToAngle(360.0);
                            rt4.setCycleCount(2);
                            rt4.setAutoReverse(true);
                            rt4.setAxis(Rotate.Y_AXIS);

                            rt4.play();

                            rt4.setOnFinished(
                                new EventHandler<ActionEvent>() {

                                  @Override
                                  public void handle(ActionEvent event) {

                                    setPrimo((int) ((Math.random() * 6) + 1));
                                    RotateTransition rt5 =
                                        new RotateTransition(Duration.millis(durata), imageViewUno);

                                    rt5.setFromAngle(0.0);
                                    rt5.setToAngle(360.0);
                                    rt5.setCycleCount(2);
                                    rt5.setAutoReverse(true);
                                    rt5.setAxis(Rotate.Z_AXIS);

                                    rt5.play();

                                    rt5.setOnFinished(
                                        new EventHandler<ActionEvent>() {

                                          @Override
                                          public void handle(ActionEvent event) {

                                            setPrimo((int) ((Math.random() * 6) + 1));
                                            RotateTransition rt6 =
                                                new RotateTransition(
                                                    Duration.millis(durata), imageViewUno);

                                            rt6.setFromAngle(0.0);
                                            rt6.setToAngle(360.0);
                                            rt6.setCycleCount(2);
                                            rt6.setAutoReverse(true);
                                            rt6.setAxis(Rotate.Z_AXIS);

                                            rt6.play();

                                            rt6.setOnFinished(
                                                new EventHandler<ActionEvent>() {
                                                  @Override
                                                  public void handle(ActionEvent event) {
                                                    setPrimo(lancioCorrente);
                                                    if (flag) {
                                                      gm.turnoSuccessivo(lancioCorrente);
                                                      System.err.println("1 CASO");
                                                    } else {
                                                      ((GameManagerNetwork) gm)
                                                          .turnoSuccessivoDiRichiesta(
                                                              lancioCorrente);
                                                      System.err.println("2 CASO");
                                                    }
                                                  }
                                                });
                                          }
                                        });
                                  }
                                });
                          }
                        });
                  }
                });
          }
        });
  }