双缓冲:
换图片时,extends JPanel可代替双缓冲。
或直接使用双缓冲双缓冲代码:
private Image offScreenImage=null;
public void update(Graphics g){
if(offScreenImage==null){
offScreenImage=this.createImage(Constant.Game_WIDTH,Constant.Game_HEIGHT);
}
Graphics gOff=OffScreenImage.getGraphics();
paint(gOff);
g.drawImage(offScreenImage,0,0,null);
}