Sign in to follow this  

[java] Buffered images still flickering !

This topic is 4686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a game up and running in Java which uses double buffering. However the first time each image of a sprite animation is shown it flickers. For instance when I walk the main character to the left for the first time the character flickers, but when I walk left from then on the animation is smooth. Why is this ? Could it be something do do with the way I obtain my images... <CODE> Image img; img = Toolkit.getDefaultToolkit().getImage("sprites/up" + currentFrame + ".png"); BufferedImage bi = new BufferedImage(50, 100, BufferedImage.TYPE_INT_ARGB); bi.getGraphics().drawImage(img, 0,0, null); g.drawImage(bi,x,y, null); </CODE> Any ideas ?

Share this post


Link to post
Share on other sites
I already wrote to you how to load your images better here:

http://www.gamedev.net/community/forums/topic.asp?topic_id=300467

and I explained that you need to post some other code for us to help better solve your problem, if that does not fix it.

Two other things: Remember to dispose your graphics, and, if you read the API for getImage(), you will see that multiple calls to getImage() with the same String, will be attempted cached, but that this may have side-effects, so you should try another approach. You could also be careful not to load your images and then immediately try to draw them afterwards. In a normal game, you have a loop, and whereas images might be loaded when a game object is created (in its constructor), they are not drawn until the render-loop reaches the object.

Share this post


Link to post
Share on other sites

This topic is 4686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this