5 replies
by epepke
Double-buffering is a means of avoiding annoying screen flicker when a screen is redrawn. Instead of erasing and drawing directly to the screen, do it to an off-screen buffer. Then, when the drawing is completely done, copy the off-screen buffer onto the screen. As the bits themselves are copied in sequence from the top of the screen to the bottom, flicker is minimized. On most systems, an entire frame can be copied in less than the time of a single screen refresh, completely eliminating flicker.
Java handles this in a partially system-dependent way using the Image class. It can be drawn to using a Graphics object in just the same way that one draws to a frame on the screen. It is system-dependent enough to be drawn efficiently and quickly on the screen using the Graphics.drawImage method.
The book Secrets of the _Java Game Programming Wizards_ gives some excellent examples of double-buffering. One trick that you need to know is that the update method must be overridden to eliminate flicker caused by drawing the background under certain circumstances.
by gnag78
by gnag78
This discussion is closed to new replies.
Trending IT Employment posts
Sort by Trending