I have been trying to solve this problem for a while. I am trying to have an animation loop run at a moderate frame rate (30) in full screen mode and I cannot seem to eliminate the flicker. At first i thought it was caused by an inaccurate timer but after implementing the hi res timer hack from the shared code section, my problem is still there. I have posted my animation loop in hops that someone could help me. I was wonering if anyone has fixed this situation for themselves?
frameTimer = new SleepTimer();
frameTimer.setDelay(1000 / fps);
frameTimer.setAutoCorrection(true, fps);
frameTimer.startTimer();
myPaint(g);
}
////////////ANIMATION LOOP///////////////////////
public void go()
{
while (true)
{
rect.moveSideways();
rect2.moveSideways();
rect3.moveSideways();
try {
synchronized(frameTimer) {
frameTimer.wait();
}
}
catch (InterruptedException iE) {
System.err.println("Interrupted Error: " +
iE.getMessage());
}
myPaint(g);
}
I guess that since the timer has it’s own thread then I do not need an animation thread and there for my program does not implement Runnable. Any help would be greatly appreciated.