【发布时间】:2015-08-06 09:59:39
【问题描述】:
嘿,我正在尝试制作一个简单的 2d 滚动条,但我似乎无法让图片滚动。我正在为图片使用 ImagveView,并且我尝试了 translatetransition 和 pathtransition,但我无法获得任何好的结果?这是我的代码:
public void aboutSceneAnimation() {
Rectangle2D psb = Screen.getPrimary().getVisualBounds();
Path path = new Path();
MoveTo moveTo = new MoveTo();
moveTo.setX(0.0);
path.getElements().add(moveTo);
PathTransition pt = new PathTransition();
pt.setDuration(Duration.INDEFINITE);
pt.setNode(map);
pt.setPath(path);
pt.setCycleCount(4);
pt.setAutoReverse(true);
pt.play();
}
public Scene aboutScene() {
Rectangle2D psb = Screen.getPrimary().getVisualBounds();
//Create the map
BorderPane border = new BorderPane();
border.getChildren().addAll(map2);
//Size the map
map2.setFitWidth(psb.getWidth());
map2.setFitHeight(psb.getHeight());
Scene scene = new Scene(border, 500, 500);
aboutSceneAnimation();
return scene;
}
它的工作方式是当程序启动时,会在我的舞台中加载一个开始场景,然后我只是展示舞台。当按下按钮时,我只需更改为也调用 aboutSceneAnimation 的 aboutScene,这是我希望地图滚动的位置。任何想法将不胜感激!
-干杯
【问题讨论】:
标签: animation javafx path scroller translate-animation