在窗格中的行后留下线索

我有一条代码在窗格中弹跳,但是我希望这条线留下痕迹,我不知道该怎么做。我在网上看到了一些图形示例,但是我不知道这是开始的正确位置,还是什至不知道如何使用它。有人可以帮我在生产线后面留下足迹吗? (好像线条被画出来了,这就是我最初的目标,但线条看起来像个球) 谢谢!

Timeline timeline = new Timeline(new KeyFrame(Duration.millis(20),new EventHandler<actionEvent>() {


        double dx = speed * Math.cos(angle); //Step on x or velocity
        double dy = speed * Math.sin(angle); //Step on y

        @Override
        public void handle(actionEvent t) {
            //move the ball
            line.setLayoutX(line.getLayoutX() + dx);
            line.setLayoutY(line.getLayoutY() + dy);

            Bounds bounds = pane.getBoundsInLocal();

            //If the ball reaches the left or right border make the step negative
            if(line.getLayoutX() <= (bounds.getMinX() + line.getStrokeWidth()) || 
                    line.getLayoutX() >= (bounds.getMaxX() - line.getStrokeWidth()) )
                dx = -dx;

            //If the ball reaches the bottom or top border make the step negative
            if((line.getLayoutY() >= (bounds.getMaxY() - line.getStrokeWidth())) ||
                    (line.getLayoutY() <= (bounds.getMinY() + line.getStrokeWidth())))
                dy = -dy;
        }
    }));
TYCandy 回答:在窗格中的行后留下线索

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3047344.html

大家都在问