0

I'm creating a simple Breakout game and I've encountered a couple of problems. First off, I need to render the bricks, the paddle, etc... I need to generally render everything on the screen that's needed. However, I don't want, for example, the bricks to continuously render; you can see where the render is occurring as it happens. There's a flash of white.

So, my question is: is it possible to render only certain objects, or more specifically, only render what needs to be rendered?

Every time I call repaint(); I don't want the whole screen to clear and repaint.

user3422952
  • 319
  • 2
  • 8
  • 17
  • 1
    This is how custom painting works. You shouldn't be overriding paint, but instead override paintComponent of something that extends from JComponent, like JPanel instead, it's double buffered by default – MadProgrammer Apr 15 '14 at 10:15
  • Take a look at [Painitng in AWT and Swing](http://docs.oracle.com/javase/tutorial/uiswing/painting/) to get a better idea of how painting is done – MadProgrammer Apr 15 '14 at 10:17
  • Thanks, but is what I'm trying to do possible without AWT/Swing? – user3422952 Apr 15 '14 at 10:23
  • Not unless you want to use JavaFX...[Heres an example](http://stackoverflow.com/questions/14886232/swing-animation-running-extremely-slow/14902184#14902184) of 4000, component based objects moving randomly across the screen. Because of the way this works, this would actually be more taxing then using a single paint method. The problems not with the API but with the way your using it. – MadProgrammer Apr 15 '14 at 10:25

0 Answers0