开发者

Java Graphics2D and blitting

Quick Java graphics question. From all the graphics tutorials I've seen it looks like using Graphics2D the entire canvas is repainted. I'm trying to make a game and I'm wondering if there's a way to only paint the parts of the canvas t开发者_运维知识库hat are to be updated on a certain cycle. Do you guys know if this is possible / necessary?


You can use repaint(x,y,w,h) to cause only a portion of the component to be updated. But afaik most java games implement some kind of offscreen painting (i.e. they render the complete scene into a bitmap) and flip this entire bitmap to the screen periodically.

The problem with the standard Swing repaint mechanism is that you have no means to exactly control when the new frame is painted (repaint causes the control to be repainted 'as soon as possible'...)

You might want to look at

  • Leightweight Java Game Library
  • Java Active Rendering

for further information/ideas on java game development.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜