【发布时间】:2013-08-21 01:32:59
【问题描述】:
我会知道我的实现对于双缓冲图像是否正确.. 因为我注意到我在屏幕中移动的图像边框会颤抖...这很正常吗??
public void paintComponent(Graphics g) {
Image bufferimage= createImage(180,180);
Graphics dbg= bufferimage.getGraphics();
//clean the screen
dbg.setColor(new Color(100,100,100));
dbg.fillRect(0,0,getWidth(),getHeight());
if (game_is_running) {
// draw various type of object with drawImage
for(int i=0; list[i]!=null; i++) {
list[i].draw(dbg);
}
target.draw(dbg);
I.draw(dbg);
}
//finally draw the image linked to graphics
g.drawImage(bufferimage,0,0,this);
}
【问题讨论】:
标签: java swing bufferedimage double-buffering