dimanche 8 novembre 2020

How to repeat animations with new randomized x and y value each loop in Java

public void activate(){

      Move();

      TranslateTransition poff = new TranslateTransition(SEC_01);
      poff.setFromX(posX);
      poff.setFromY(posY);
      poff.setToX(posX + getMoveX());
      poff.setToY(posY + getMoveY());


public void Move(){
      RandomCoordinateGenerator rand = new RandomCoordinateGenerator();
      rand.setMove();
      this.move(rand.getxMove(), rand.getyMove());
  }

I have a method activate that invoke Move() which uses a class to generate and set random x y value (to be retrieved by getter). I run it using a for loop so that this MOVE would generate a new random generator and x y but the x y are only repeating the same value over and over. Any idea how I can fix this?




Aucun commentaire:

Enregistrer un commentaire