初学canvas,模仿google(let it snow)遇到问题

阅读更多
先贴出代码


 function Snow(x, y, s){
		this.x = x;
		this.y = y;
		this.s = s;
	    }
	    Snow.prototype.draw = function(ctx, canvas){
		ctx.save();
		    var imageObj = new Image();
		    var x = this.x;
		    var y = this.y;
		    var s = this.s;
		    imageObj.onload = function(){
			ctx.drawImage(imageObj, x, y, s, s);
		    };
		    imageObj.src = "snow.png";
		ctx.restore();
		if(this.y < 600){
		    this.y += 6;
		    if(Math.random() < 0.3){
			if(Math.random() > 0.3){
			    this.x += Math.random()*2;
			}else{
			    this.x -= Math.random()*2;
			}
		    }
		    
		}else{
		    snowCanvas.remove(this);
		}
	    }
	    function snowDown(){
		snowCanvas.add(new Snow(Math.random()*document.body.clientWidth-100, 0, Math.random() * 30)).play(150);
	    }

	    setInterval(snowDown,500);




使用得是  gury这个框架.
能展示出雪花从天降落得效果,但是总是闪烁,显得不连贯...请问各位高人..怎么解决这种问题

你可能感兴趣的:(JavaScript,HTML5,jQuery)