Jump to content
  • Advertisement
Sign in to follow this  
chris_j_pook

[java] Buffered images still flickering !

This topic is 5049 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!