1

I am trying to implement enemies that spawn periodically and go through a longer transition cycle. The gap between enemies spawning is far too long. Any recommendations would be helpful

I've tried to set the duration cycle to a bunch of different lengths, setting it to a low duration (5 seconds) makes the animation go by too quick for what I want

public class enemyCollection extends gameController{

private Rectangle grunte;


public enemyCollection(Rectangle grunt, Rectangle spawnBox, AnchorPane pane) {
                                                            //Creates base Grunt Unit
    Rectangle grunte = new Rectangle();
    grunte.setHeight(30);
    grunte.setWidth(30);
    grunte.setFill(javafx.scene.paint.Color.RED);
    grunte.setLayoutX(1863);
    grunte.setLayoutY(33);

                                                            //Code of the generic Path
    Path path = new Path();

    path.getElements().add(new MoveTo(1863,33));        


                                                            //Start Coordinates
    double startX = -15;
    double endX = -115;
                                                            //Loop's rest of enemy path
    for(int i = 0; i <= 6 ; ++i) {

        path.getElements().add(new LineTo(startX, 10));
        path.getElements().add(new LineTo(startX, 1000));
        path.getElements().add(new LineTo(endX, 1000));
        path.getElements().add(new LineTo(endX, 10));
        path.getElements().add(new LineTo(endX - 100, 10));

        startX = endX - 200;
        endX = endX - 300;



    }
    pane.getChildren().add(grunte);                                     //Adds path to grunt unit
    PathTransition pathT = new PathTransition();

    pathT.setDuration(Duration.seconds(5));
    pathT.setPath(path);
    pathT.setNode(grunte);
    pathT.setCycleCount(PathTransition.INDEFINITE);
    pathT.setAutoReverse(false);
    pathT.setInterpolator(Interpolator.LINEAR);
    pathT.play();
    pane.getChildren().add(grunte); 












}

I expect enemies to spawn rather continuously and them to go through a long animation cycle

ijcmian
  • 11
  • 1

0 Answers0