title: JavaFX animations using loops?
body: <p>I'm trying to build a space invaders like game. 
  I've drawn a square and I want to move it down incrementally by using a loop and <code>thread.sleep</code>. However, the square just gets drawn immediately. I understand there are animation paths that could be used but I want to stay low level and just use a coordinate system.</p>
  
  <p>Is there a way of making a timeline animation by using a loop like this?</p>
  
  <pre><code>package com.company;
  
  import javafx.application.Application;
  import javafx.stage.Stage;
  import javafx.scene.*;
  import javafx.scene.layout.*;
  import javafx.scene.shape.Rectangle;
  
  public class Main extends  Application  {
  
      public static void main(String[] args)  {
          // write your code here
          launch(args);
      }
  
      public void start(Stage myStage) throws InterruptedException {
          myStage.setTitle("space invaders");
  
          Pane rootNode= new Pane();
          Scene myScene=new Scene(rootNode, 400, 800);
          myStage.setScene(myScene);
          Rectangle r = new Rectangle();
          myStage.show();
          rootNode.getChildren().add(r);
          r.setX(50);
          r.setY(50);
          r.setWidth(20);
          r.setHeight(20);
  
          for (int i = 0; i &lt; 500; i++){
              Thread.sleep(2000);
              r.setTranslateY(i);
          }
      }
  }
  </code></pre>