1. How to stop flickering?!! coderanch.comyou can use "double buffering" by creating the image "off-screen" first, and then copying it to the real screen. import java.awt.*; import java.applet.*; public class Flicker extends java.applet.Applet { Image offscreenImg; Graphics offscreen; public void init() { offscreenImg = createImage( getSize().width, getSize().height ); offscreen = offscreenImg.getGraphics(); } public void paint( Graphics screen ) { offscreen.setColor( Color.blue ); offscreen.fillRect( 0, 0, 100, ... |
2. Flickering problem coderanch.comI am using java to write a little game in which I have a background that keeps moving while other elements of the game such as plane, monsters keep moving on the background,too. Now, everytime the background re-renders itself, it will clear the whole background that includes my monsters, planes...etc, and then the whole world will be redrawn again. This gives ... |
3. avoiding flickering coderanch.comHmmm... there were lots of problems with the code... I *think* the problem that was causing the flickering was the overridden paint method for the JFrame, you should probably make it a JPanel and override the JPanel's paintComponent() method. Also, you were re-loading the background image every time it needed to repaint. This was also probably adding to the flicker problem. ... |
4. advanced flickering coderanch.com |
5. How to avoid flickering coderanch.com |