相关疑难解决方法(0)

如何使动画彼此重叠而不是并排播放?

我是fx动画的新手,我正在尝试在另一个动画完成后立即播放一个动画。但是,相反,这两个动画都是在舞台的另一侧同时播放的。另外,是否有一种方法可以更改通过JavaFX显示的图像的大小而不更改图像的像素大小?

我尝试将动画的布局x和y设置为相同,以便可以相互播放。

package application;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;

public class Main extends Application {

    // LOAD IMAGES======================================================================

    // load in sun images
    final static javafx.scene.image.Image sun1 = new javafx.scene.image.Image(
            Main.class.getResource("/Sun/Sun1.png").toString());
    final static javafx.scene.image.Image sun2 = new javafx.scene.image.Image(

    // load in rain images
    final static javafx.scene.image.Image rain1 = new javafx.scene.image.Image(
            Main.class.getResource("/Rain/Rain1.png").toString());
    final static javafx.scene.image.Image rain2 = new javafx.scene.image.Image(
            Main.class.getResource("/Rain/Rain2.png").toString());

    // create a group …
Run Code Online (Sandbox Code Playgroud)

java animation javafx

6
推荐指数
0
解决办法
104
查看次数

JavaFX和SVG:绘制一条线

我正在使用JavaFX来渲染一些SVG的东西.我定义了很多方法,返回不同SVG形状的路径(省略号,圆形,矩形,线条等).除线法外,所有这些似乎都有效.JavaFX不会返回错误(意味着路径可能正确),但它不会绘制任何内容.这是我的方法.

public static SVGPath line(float startX, float endX, float startY, float endY, PositionType positionType)
{
    SVGPath path = new SVGPath();
    path.setContent(positionType.getMoveto()+startX+","+startY+positionType.getLineto("l")+endX+","+endY);    

    return path;    
}
Run Code Online (Sandbox Code Playgroud)

该方法getMoveto()返回M或m,取决于PositionType,并getLineto()返回L或l.

这是一个示例方法调用:

SVGPath test2 = SVGPrimitives.line(20f, 30.1f, 23f, 89.21f, PositionType.ABSOLUTE);
Run Code Online (Sandbox Code Playgroud)

以下是返回的路径:

M20.0,23.0 L 30.1,89.21
Run Code Online (Sandbox Code Playgroud)

这似乎对我有用,但没有任何内容......

java svg javafx

2
推荐指数
1
解决办法
4921
查看次数

标签 统计

java ×2

javafx ×2

animation ×1

svg ×1