【发布时间】:2016-01-10 18:35:08
【问题描述】:
package example;/**
* Created by tri___ton on 09.01.16.
*/
import javafx.animation.ScaleTransition;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
import javafx.util.Duration;
public class AnimationSequence extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Stage stage = new Stage();
Group group = new Group();
Image first = new Image("http://hq-oboi.ru/photo/kotik_kak_pushistyy_komochek_1920x1200.jpg", 100.0, 100.0, true, true);
ImageView firstImage = new ImageView();
firstImage.setImage(first);
Image second = new Image("http://hq-wallpapers.ru/wallpapers/2/hq-wallpapers_ru_animals_8040_1280x1024.jpg", 100.0, 100.0, true, true);
ImageView secondImage = new ImageView();
secondImage.setImage(second);
secondImage.setLayoutX(150);
secondImage.setLayoutY(150);
group.getChildren().add(firstImage);
group.getChildren().add(secondImage);
Scene scene = new Scene(group, 300, 300);
stage.setScene(scene);
stage.show();
ScaleTransition ft = new ScaleTransition(Duration.millis(3000));
ft.setByX(1.5);
ft.setByY(1.5);
ft.setNode(firstImage);
ft.play();
ScaleTransition st = new ScaleTransition(Duration.millis(3000));
st.setNode(secondImage);
st.setByX(1.5);
st.setByY(1.5);
st.play();
}
}
这只是简单的代码示例。
我需要一个接一个地做动画。
动画优先 超时 3 秒。 动画秒。
我该怎么做?
最大的问题是如何在主线程的不同部分之间暂停。
【问题讨论】:
-
有无数的例子来说明如何用 Java 制作动画。我建议你读一些。其中一些在演示下载中带有 Java。