海葵
draw:function(deltaTime){ // console.info("draw deltaTime is : "+ deltaTime); this.cantx.save(); this.cantx.globalAlpha=0.3; // 线宽 this.cantx.lineWidth=10; // 端点样式 this.cantx.lineCap="round"; // 颜色 this.cantx.strokeStyle="#3b154e"; for (var i = 0; i < this.num; i++) { // console.info(this.anes.x + deltaTime); // console.info(this.can.height - this.anes.len); // beginPath, moveTo,lineTo,stroke,strokeStyle,lineWidth,lineCap, // 开始绘制路径 this.cantx.beginPath(); // 指针跳到某点 this.cantx.moveTo(this.anes.x,this.can.height); // 画到某点 this.cantx.lineTo(this.anes.x , this.can.height - this.anes.len); // console.info("x "+this.anes.x+ ",y "+this.can.height+ ",tx "+this.anes.x+" ,ty"+this.can.height - this.anes.len); // 开始绘制 this.cantx.stroke(); } this.cantx.restore(); }
实物
fruitDraw.prototype = { draw : function(deltaTime){ // 成长 for (var i = this.fruits0.length - 1; i >= 0; i--) { var fruit = this.fruits0; // console.info("growing"); // this.cantx.drawImage(fruit.img,fruit.x-10,fruit.y-10); this.cantx.drawImage(fruit.img,fruit.x - fruit.size * 0.5, fruit.y - fruit.size * 0.5, fruit.size, fruit.size); this.growing(i,deltaTime); } // 上浮 for (var i = this.fruits1.length - 1; i >= 0; i--) { var fruit = this.fruits1; // console.info("drifted"); // this.cantx.drawImage(fruit.img,fruit.x-10,fruit.y-10); this.cantx.drawImage(fruit.img,fruit.x - fruit.size * 0.5, fruit.y - fruit.size * 0.5, fruit.size, fruit.size); this.drifted(i,deltaTime); } } } |