Animation 魔方组成立方体的旋转';s立方体
我通过排列更小的立方体制作了一个魔方。现在我想对其应用动画。为此,我选择使用Rotate类并设置旋转角度和旋转轴,如下所示Animation 魔方组成立方体的旋转';s立方体,animation,3d,rotation,javafx-8,Animation,3d,Rotation,Javafx 8,我通过排列更小的立方体制作了一个魔方。现在我想对其应用动画。为此,我选择使用Rotate类并设置旋转角度和旋转轴,如下所示 ar[12].setRotationAxis(Rotate.X_AXIS);//The array elements refer to the small cubes which make up the Rubik's cube.These elements represent the left face. ar[13].setRotationAxis(Ro
ar[12].setRotationAxis(Rotate.X_AXIS);//The array elements refer to the small cubes which make up the Rubik's cube.These elements represent the left face.
ar[13].setRotationAxis(Rotate.X_AXIS);
ar[14].setRotationAxis(Rotate.X_AXIS);
ar[15].setRotationAxis(Rotate.X_AXIS);
Rotate rotation1 = new Rotate(90);
rotation1.setAxis(Rotate.X_AXIS);
Timeline timeline = new Timeline(
new KeyFrame(Duration.seconds(2), new KeyValue(ar[12].rotateProperty(), 90)),
new KeyFrame(Duration.seconds(2), new KeyValue(ar[13].rotateProperty(), 90)),
new KeyFrame(Duration.seconds(2), new KeyValue(ar[14].rotateProperty(), 90)),
new KeyFrame(Duration.seconds(2), new KeyValue(ar[15].rotateProperty(), 90)));
timeline.play();
然后我将旋转应用为动画,如下所示
ar[12].setRotationAxis(Rotate.X_AXIS);//The array elements refer to the small cubes which make up the Rubik's cube.These elements represent the left face.
ar[13].setRotationAxis(Rotate.X_AXIS);
ar[14].setRotationAxis(Rotate.X_AXIS);
ar[15].setRotationAxis(Rotate.X_AXIS);
Rotate rotation1 = new Rotate(90);
rotation1.setAxis(Rotate.X_AXIS);
Timeline timeline = new Timeline(
new KeyFrame(Duration.seconds(2), new KeyValue(ar[12].rotateProperty(), 90)),
new KeyFrame(Duration.seconds(2), new KeyValue(ar[13].rotateProperty(), 90)),
new KeyFrame(Duration.seconds(2), new KeyValue(ar[14].rotateProperty(), 90)),
new KeyFrame(Duration.seconds(2), new KeyValue(ar[15].rotateProperty(), 90)));
timeline.play();
但是有了这个,我得到的结果是
.
正如我所理解的,我得到的是每个立方体,但我对每个立方体的要求是立方体必须围绕其边缘旋转90度。我怎样才能做到这一点?还有一个问题是,鼠标单击一次后,即使动画也不会再次出现。我如何解决这个问题?看看这个,它将向您展示一种处理旋转和动画的可能方法好的,这真的很有帮助,我可以做些什么,让我的动画在每次单击鼠标时播放?您有所有的代码,看一看。您能详细解释一下旋转和动画部分吗,很抱歉,我是个新手,不太懂。具体来说,“听时间线如何在内部插值,在新角度和旧角度之间进行小旋转”,这意味着什么?您是如何将其应用于
仿射类的?。如果可能的话,有没有一种更简单的方法可以应用到我的代码中?