Java 2D Drawing Optimal Performance

前端 未结 9 1922
我寻月下人不归
我寻月下人不归 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: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

提交回复
热议问题