java之双缓冲的代码粘贴

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);

 

posted @ 2018-08-17 15:54  SteveYu  阅读(561)  评论(0编辑  收藏  举报