浅谈利用缓存来优化HTML5 Canvas程序的性能

2020-04-24 18:59:39易采站长站整理

                        this.vy = -this.vy;   
                    }   
  
                    this.paint(ctx);   
                }   
            }   
  
            var Game = {   
                init:function(){   
                    for(var i=0;i<1000;i++){   
                        var b = new ball(getRandom(0,canvas.width) , getRandom(0,canvas.height) , getRandom(-10 , 10) ,  getRandom(-10 , 10) , true)   
                        Balls.push(b);   
                    }   
                },   
  
                update:function(){   
                    ctx.clearRect(0,0,canvas.width,canvas.height);   
                    for(var i=0;i<Balls.length;i++){   
                        Balls[i].move();   
                    }   
                },   
  
                loop:function(){   
                    var _this = this;