1static int speed x ;
2// prefered speed to start with = 5;
3
4new AnimationTimer(){
5 long lastTick = 0;
6 @Override
7 public void handle(long now){
8 if(lastTick == 0 ){
9 frame();
10 lastTick = now ;
11 return;
12 }
13 if(now - lastTick > 1000000000 / speed){
14 frame();
15 lastTick = now;
16 }
17
18 }
19 }.start();