我正在尝试使用animation timer handle(现在很久)方法来更改旋转动画(x,y,z和vv)的参数,但是我不知道如何在每次迭代时重定向值。 / p>
我尝试过将构造函数放在那里:
Cylinder cyli = new Cylinder(200,40);
Translate trans3 = new Translate(0, 0, 0);
cyli.getTransforms().add(trans3);
cyli.setMaterial(pm);
cyli.setDrawMode(DrawMode.LINE);
Group group = new Group();
group.setTranslateX(150);
group.setTranslateY(150);
group.setTranslateZ(100);
rotate = new Rotate(0, axis);
group.getTransforms().setAll(rotate);
group.getChildren().add(cyli);
center.getChildren().add(group);
final Timeline rotationAnimation = new Timeline();
rotationAnimation.setCycleCount(1);
timer = new AnimationTimer() {
@Override
public void handle(long now) {
axis = new Point3D(x, y, z);
rotate = new Rotate(0, axis);
speed = 1/vv;
duration = Duration.seconds(speed);
//x, y, z and vv are values set by the user (variables)
}
};
duration = Duration.seconds(speed);
KeyValue keyValue1 = new KeyValue(rotate.angleProperty(),360);
KeyFrame keyFrame1 = new KeyFrame(duration, keyValue1);
rotationAnimation.getKeyFrames().add(keyFrame1);
rotationAnimation.play();
timer.start();
我想在动画期间或动画之间更改x,y,z和vv值,可以在任何给定时间更改这些值,但它们保持不变。我开始想,我将需要以某种方式将整个团队转移到handle方法,但是我不知道该如何处理。