Мой код показан ниже. Я хочу, чтобы "ball" был прикреплен к "circle1" и go вдоль объекта "circle1", "pathtransition2" - мой код для этой цели, но он не работает.
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.event.ActionEvent;
import javafx.scene.shape.Circle;
import javafx.animation.PathTransition;
import javafx.animation.Timeline;
import javafx.util.Duration;
public class windows7 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
public void start(Stage mystage) {
Circle circle1 = new Circle(370, 370, 50);
Circle ball = new Circle(370, 370, 11);
Circle path = new Circle(370, 370, 300);
circle1.setStroke(Color.GRAY);
circle1.setFill(null);
ball.setFill(Color.BLACK);
Pane pane = new Pane(circle1, ball);
Scene scene = new Scene(pane, 740, 740);
mystage.setScene(scene);
mystage.show();
PathTransition pathtransition = new PathTransition(new Duration(4000), path, circle1);
pathtransition.setCycleCount(Timeline.INDEFINITE);
pathtransition.play();
PathTransition pathtransition2 = new PathTransition(new Duration(3000), circle1, ball);
pathtransition2.setCycleCount(Timeline.INDEFINITE);
pathtransition2.play();
}
}