Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 16 ■ 3D Game animation Creation: UsinG the animation transition Classes


RotateTransition rotGameBoard, rotSpinner;
...
private void createAnimationAssets() {
rotGameBoard = new RotateTransition(Duration.seconds(5), gameBoard);
rotGameBoard.setAxis(Rotate.Y_AXIS);
rotGameBoard.setCycleCount(1);
rotGameBoard.setRate(0.5);
rotGameBoard.setInterpolator(Interpolator.LINEAR);
rotGameBoard.setFromAngle(45);
rotGameBoard.setToAngle(1125);
rotGameBoard.play();
rotSpinner = new RotateTransition(Duration.seconds(5), spinner);
rotSpinner.setAxis(Rotate.Y_AXIS);
rotSpinner.setCycleCount(1);
rotSpinner.setRate(0.5);
rotSpinner.setInterpolator(Interpolator.LINEAR);
rotSpinner.setFromAngle( 30 );
rotSpinner.setToAngle( 1110 );
rotSpinner.play();
}


Figure 16-6. Add a rotateSpinner RotateTransition object and configure it with the same parameters as
rotGameBoard

Free download pdf