老师我的海葵颜色是黑色的

来源:2-3 海葵绘制

qq_一帆风顺_0

2015-10-15 17:15

var aneObj = function()
{
	this.x = [];
	this.len = [];
}
aneObj.prototype.num =50;
aneObj.prototype.init = function()
{
	for (var i = 0; i < this.num; i++) {
		this.x[i] = i * 16 + Math.random() * 20;//[0,1) 
        this.len[i] = 200 + Math.random() * 50;
	}
}	
aneObj.prototype.draw = function()
{   
    ctx2.save(); 
    ctx2.globalAlbha = 0.6;
	for (var i = 0; i < this.num; i++) {
		//beginPath,moveTo,linTo,stroke,starokeStyle,linewidth,lineCap,globalAlbha
		ctx2.beginPath();
		ctx2.moveTo(this.x[i],canHeight);
		ctx2.lineTo(this.x[i],canHeight - this.len[i]);
		ctx2.lineWidth = 20;
		ctx2.lineCap = "round";
		ctx2.starokeStyle = "#3b154e";
		ctx2.stroke();
	}
	ctx2.restore();
}

http://img.mukewang.com/561f6e6500017ab208130629.jpg

写回答 关注

2回答

  • 慕用7077196
    2015-10-19 17:40:44
    已采纳

        ctx2.strokeStyle = "#3b154e"; 你写的strokeStyle 多了一个a

  • f2e_yuning
    2015-10-21 14:08:44

    透明效果的 17行的ctx2.globalAlbha = 0.6;  應該為globalAlpha  

HTML5小游戏---爱心鱼(上)

学做HTML5游戏,轻轻松松带你上手,适合刚入手游戏开发的同学

92353 学习 · 550 问题

查看课程

相似问题