Hi everyone I'm new to the forums and I really hope I can get some help with this problem
I've been working really hard lately looking everywhere to try and figure out how to get my Java animations to flow smoothly, the main problem I have is the animation runs smooth with hiccups every 2 seconds where the animation appears to "pop" ahead of itself and then "pop" back making the animation look choppy.
Here's a short example that I created to show you guys the problem i'm having. Should be easy to compile and run if you wanna give it a try. When you run it you'll see a blue rectangle slide back and fourth on the screen, if you watch it for a bit you should notice that the rectangle seems to stop and start briefly, or "pop" ahead of itself and then jump back making the animation kinda choppy.
So my question is, what could be causing this? Any suggestions on the code or maybe some ideas on better ways to achieve a nice animation?
Thank you all for taking the time
I've also tried the following to account for the time it might take to draw a frame and compensate for the that time by sleeping less if the frame took time to draw, didn't seem to help :/
From that thread, it appears you have been digging deeper into possible causes for your problem. How about sharing your findings here?
Thanks for your reply
I didn't mention the post I made on java-forums.org because I've tried animations on various computers, I get the same stuttering regardless of whether hardware acceleration is present therefore I've ruled out the lack of hardware acceleration being the culprit. My question on that forum was regarding why hardware acceleration is not present on a particular machine, my question here is why my animations in general on all platforms are not fluid and how I might go about improving their performance.
I've also tried the Timer approach with no luck I still get the same stuttering every 2 or so seconds where the animation appears to jump forward and then back again. Really stumped I'm not sure what could be causing this even after a lot of research. There's got to be a way to make it stutter free or at least very close to it.
Thanks again for your help!
Joined: Jul 02, 2012
Also seems to have the stuttering using a BufferStrategy and full screen exclusive mode, could this have something to do with Vertical Sync? Or the lack of it? Though I would expect to see the frame cut in half as the screen updates not the whole animation stutter: