六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 215|回复: 0

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

[复制链接]

升级  74%

9

主题

9

主题

9

主题

童生

Rank: 1

积分
37
 楼主| 发表于 2013-1-29 08:52:40 | 显示全部楼层 |阅读模式
先贴出代码

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这个框架.
能展示出雪花从天降落得效果,但是总是闪烁,显得不连贯...请问各位高人..怎么解决这种问题
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表