Java 2D Drawing Optimal Performance

前端 未结 9 1852
我寻月下人不归
我寻月下人不归 2020-12-04 09:46

I\'m in the process of writing a Java 2D game. I\'m using the built-in Java 2D drawing libraries, drawing on a Graphics2D I acquire from a BufferStrategy from a Canvas in a

相关标签:
9条回答
  • 2020-12-04 10:46

    make sure you use double buffering, draw first to one big buffer in memory that you then flush to screen when all drawing is done.

    0 讨论(0)
  • 2020-12-04 10:47

    There are couple of things you will need to keep in mind

    1) is refreshing this link shows how to use swingtimers which might be a good option for calling repaint. Getting repaint figured out (as the previous posters have said is important so you're not doing too much work).

    2) Make sure you're only doing drawing in one thread. Updating UI from mulitple threads can lead to nasty things.

    3) Double Buffering. This makes the rendering smoother. this site has some more good info for you

    0 讨论(0)
  • 2020-12-04 10:51

    An alternative if you don't want to go pure Java 2D is to use a game library such as GTGE or JGame (search for them on Google), then offer easy access to graphics and also offer double buffering and much simpler drawing commands.

    0 讨论(0)
提交回复
热议问题