timeline.setAutoReverse(true); timeline.setCycleCount(Timeline.INDEFINITE);
KeyValue start = new KeyValue(enemy.translateXProperty(), 0); KeyValue end = new KeyValue(enemy.translateXProperty(), 600); KeyFrame startFrame = new KeyFrame(Duration.ZERO, start); KeyFrame endFrame = new KeyFrame(Duration.seconds(5), end); Timeline timeline = new Timeline(startFrame, endFrame); timeline.setAutoReverse(true); timeline.setCycleCount(Timeline.INDEFINITE); timeline.play();
final void hide(EventHandler<ActionEvent> nextAction){ final Timeline timeline = new Timeline(); timeline.setCycleCount(1); timeline.setAutoReverse(true); final KeyValue[] kvArray = new KeyValue[2]; kvArray[0] = new KeyValue(this.getNode().scaleXProperty(), 0); kvArray[1] = new KeyValue(this.getNode().scaleYProperty(), 0); final KeyFrame kf = new KeyFrame(Duration.millis(500), kvArray); timeline.getKeyFrames().add(kf); // here we call function from parameter timeline.setOnFinished(nextAction); timeline.play(); }
double oldx = RBar.getX(); double oldy = RBar.getY(); double moveval = oldacc + averageACC; double angle = -30 * Math.PI / 180; double newx = oldx - moveval * Math.sin(angle); double newy = oldy - moveval * Math.cos(angle); double movex = newx + oldx; double movey = newy + oldy; Platform.runLater(new Runnable() { @Override public void run() { final Timeline timeline = new Timeline(); timeline.setCycleCount(1); timeline.setAutoReverse(true); final KeyValue targetkvx = new KeyValue(RBar.translateXProperty(), movex); final KeyValue targetkvy = new KeyValue(RBar.translateYProperty(), movey); final KeyFrame kf = new KeyFrame(Duration.millis(100), targetkvx, targetkvy); timeline.getKeyFrames().add(kf); timeline.play(); } }); oldacc = averageACC;
new KeyFrame(Duration.ZERO, new KeyValue(shadow.radiusProperty(), 0d)), new KeyFrame(Duration.seconds(0.15), new KeyValue(shadow.radiusProperty(), 20d))); shadowAnimation.setAutoReverse(true); shadowAnimation.setCycleCount(2);
timelineX.setAutoReverse(false); timelineX.play(); timelineY.setAutoReverse(false); timelineY.play();
}); timeline.setAutoReverse(true); timeline.setCycleCount(Animation.INDEFINITE); timeline.play();
public class FXMLTimeController implements Initializable { @FXML private TextField txtTime; //timeline private Timeline timeline; private void showTime() { txtTime.setText((new Date()).toString()); } @Override public void initialize(URL url, ResourceBundle rb) { timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(false); timeline.getKeyFrames().add( new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { showTime(); } })); timeline.play(); } }
Arc arc = ArcBuilder.create() .centerX(150) .centerY(150) .radiusX(100) .radiusY(50) .startAngle(0) .length(30) .type(ArcType.ROUND) .fill(Color.RED) .build(); Pane root = new Pane(); root.getChildren().add(arc); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello Arc!"); primaryStage.setScene(scene); primaryStage.show(); KeyValue kv = new KeyValue(arc.startAngleProperty(), 360); KeyFrame kf = new KeyFrame(Duration.seconds(3), kv); Timeline timeline = new Timeline(); timeline.setAutoReverse(false); timeline.setCycleCount(Timeline.INDEFINITE); timeline.getKeyFrames().add(kf); timeline.play();
@Override public void start(Stage primaryStage) { Circle circle = new Circle(300, 20, 5); Timeline animation = new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(circle.centerYProperty(), circle.getCenterY())), new KeyFrame(Duration.seconds(1), new KeyValue(circle.centerYProperty(), 300)) ); animation.setCycleCount(Animation.INDEFINITE); animation.setAutoReverse(true); Button btn = new Button("Play"); btn.pressedProperty().addListener((observable, wasPressed, pressed) -> { System.out.println("changed"); if (pressed) { animation.play(); } else { animation.pause(); } }); Pane root = new Pane(btn, circle); Scene scene = new Scene(root, 400, 400); primaryStage.setScene(scene); primaryStage.show(); }
new KeyFrame(Duration.millis(500), new KeyValue(opacity, 0))); flashAnimation.setCycleCount(Animation.INDEFINITE); flashAnimation.setAutoReverse(true);
final Timeline timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(false); KeyValue xKV = new KeyValue(c.centerXProperty(), 500); KeyValue yKV = new KeyValue(c.centerYProperty(), 100, new Interpolator() {
timeline.setAutoReverse(true); timeline.setCycleCount(Timeline.INDEFINITE);
}); timeline.setAutoReverse(creatorConfig.isAutoReverse()); timeline.setCycleCount(creatorConfig.getCycleCount()); timeline.setDelay(creatorConfig.getDelay());
private void animateWaitingLabel() { waitingLabel.translateYProperty().set(30); KeyValue kv = new KeyValue(waitingLabel.opacityProperty(), 0); Timeline timeline = new Timeline(new KeyFrame(Duration.millis(1000), kv)); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); timeline.play(); }
new KeyFrame(Duration.ZERO, new KeyValue(circle.centerYProperty(), circle.getCenterY())), new KeyFrame(duration, new KeyValue(circle.centerYProperty(), circle.getCenterY()+dy))); animation.setAutoReverse(true); animation.setCycleCount(Animation.INDEFINITE); animation.play();
final Timeline timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); final KeyValue kv = new KeyValue(icon.opacityProperty(), 0.0); final KeyFrame kf = new KeyFrame(Duration.millis(700), kv);
timeline.setAutoReverse(false);
timeline.setAutoReverse(false);
timeline.setAutoReverse(false);