Since I've been using Java I've always had the problem that whenever I try to make something move, it is a bit jerky. I was hoping that JavaFX would solve this problem but with the following code:
package test;
import javafx.animation.Interpolator;
import javafx.animation.TranslateTransition;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SmoothMovementTest extends Application {
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root, 800, 400, Color.WHITE);
stage.setScene(scene);
Circle circle = new Circle(50.0, Color.RED);
circle.setCenterX(50.0);
circle.setCenterY(200.0);
root.getChildren().add(circle);
TranslateTransition transition = new TranslateTransition(new Duration(5000.0), circle);
transition.setToX(700.0);
transition.setAutoReverse(true);
transition.setCycleCount(10);
transition.setInterpolator(Interpolator.LINEAR);
stage.setVisible(true);
transition.playFromStart();
}
public static void main(String[] args) {
Application.launch(args);
}
}
I still have the same problem.
Could someone run it on their machine please and tell me if it is jerky for them.
What I'm actually seeing is about 11 jerks per movement across the screen.
Thanks, Nick.