我已经使用HTML5画布编写了一个简单的图像滑块。每个图像到达屏幕后,将从阵列中移除,导致随机图像闪烁。我怎样才能解决这个问题。图像在画布上闪烁
的jsfiddle:http://jsfiddle.net/mbe5R/2/
this.animate = function() {
this.y += this.speed;
this.x = this.xrandom * albumWall.canvas.width - 250;
if(this.y > innerHeight) {
albumWall.fbImages.splice(albumWall.fbImages.indexOf(this),1);
if(albumWall.count==(albumWall.imgArr.length-1)) {
albumWall.count=-1;
}else{
albumWall.count++;
var img = albumWall.imgArr[albumWall.count];
console.log(img)
albumWall.fbImages.push(new self.fbImage(albumWall.count, img, img.width, img.height));
}
}
};
当图像到达窗口结束时,我正在移除
albumWall.fbImages.splice(albumWall.fbImages.indexOf(this),1);
我认为这是造成屏幕闪烁,随机的问题。
真棒谢谢! – user1184100