private SequentialTransition createTransition(
      final Point2D pntStartPoint, final Point2D pntEndPoint, ImageView imView) {

    imView =
        new ImageView(
            new Image(getClass().getResourceAsStream("/res/img/b1fh.png"), 75, 75, true, true));

    imView.setX(pntStartPoint.getX());
    imView.setY(pntStartPoint.getY() - 30);

    APMainScreen.getChildren().add(imView);

    TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), imView);
    translateTransition.setFromX(0);
    translateTransition.setToX(pntEndPoint.getX() - pntStartPoint.getX());
    translateTransition.setFromY(0);
    translateTransition.setToY(pntEndPoint.getY() - pntStartPoint.getY());

    translateTransition.setCycleCount(1);
    translateTransition.setAutoReverse(false);

    int rnd = randInt(1, 3);

    RotateTransition rotateTransition = new RotateTransition(Duration.millis(150), imView);
    rotateTransition.setByAngle(90F);
    rotateTransition.setCycleCount(rnd);
    rotateTransition.setAutoReverse(false);

    ParallelTransition parallelTransition = new ParallelTransition();
    parallelTransition.getChildren().addAll(translateTransition, rotateTransition);

    SequentialTransition seqTrans = new SequentialTransition();
    seqTrans.getChildren().addAll(parallelTransition);

    final ImageView ivRemove = imView;
    seqTrans.setOnFinished(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            APMainScreen.getChildren().remove(ivRemove);
          }
        });

    return seqTrans;
  }
Beispiel #2
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 #3
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");
                                                    }
                                                  }
                                                });
                                          }
                                        });
                                  }
                                });
                          }
                        });
                  }
                });
          }
        });
  }