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

猜你喜欢

转载自www.cnblogs.com/littlepage/p/9493754.html