@
lakechan96 ```javascript
DD.CommentFrame.prototype.render = function() {
this.ctx.clearRect(0, 0, this.width, this.height); //清空结果画布
var bufCanvasCtx = this.bufCanvas.getContext("2d");
bufCanvasCtx.clearRect(0, 0, this.width, this.height); //清空buffer画布
//渲染各层精灵到buffer画布上
for (var i = 0; i < this.layers.length; i++) {
for (var j = 0; j < this.layers[i].length; j++) {
this.layers[i][j].draw(bufCanvasCtx);
}
}
//往主图层上绘制buffer图层
this.ctx.drawImage(this.bufCanvas, 0, 0);
};
```
```javascript
(function animate() {
that.updateSprite(); //更新Sprite
that.clearSprite(); //清除无效Sprite
that.render();
that.fps = that.countFps(); // 计算FPS
that.renderTimer = window.requestAnimationFrame(animate, that);
//console.log(that.renderTimer);
})();
```