I am trying to animate movement of a rectangular sprite across the screen using keyboard controls, but I notice subtle pauses in the animation initially. There are typically one to three pauses, jerks or jitters. Then the rest of the time, the animation is generally smooth.
In the below code, I use keybindings to set boolean flags for the direction keys. Then in an animation timer, I check the flag, set the sprite's velocity and set the sprite's layout property. I restrict movement to one axis at a time. I do diagonal movement by alternating movement in each axis.
In addition, I have tried using setOnKeyPressed and setOnKeyReleased, but there was no effect on the problem.
I considered that there may be video card or memory problems with the computer, so I tried this code on two computers and the problem exists on both computers. Both computers ran the code in Windows 10 and the Eclipse IDE.
Similarly, when I run the code here, (Key Combinations), I also see these kinds of pauses in the animation, so I am worried that it might not just be my code.
Please help me resolve these subtle pauses in animating a rectangular sprite using keybindings.
Thank you very much for taking a look at my problem.