課程
/前端開(kāi)發(fā)
/HTML/CSS
/HTML5小游戲---愛(ài)心魚(yú)(上)
海葵怎么沒(méi)動(dòng)
2017-01-13
源自:HTML5小游戲---愛(ài)心魚(yú)(上) 2-7
正在回答
babyObj.prototype.draw = function () { ? ?// ctx1 ? ?this.x = lerpDistance(mum.x, this.x, 0.98); ? ?this.y = lerpDistance(mum.y, this.y, 0.98); ? ?//delta angle ? ?var deltaY = mum.y - this.y; ? ?var deltaX = mum.x - this.x; ? ?var beta = Math.atan2(deltaY,deltaX) + Math.PI; ? ?this.angle = lerpAngle(beta,this.angle,0.6); ? ?ctx1.save(); ? ?ctx1.translate(this.x, this.y); ? ?ctx1.rotate(this.angle); ? ?ctx1.drawImage(this.babyTail, -this.babyTail.width*0.5+23, -this.babyTail.height*0.5); ? ?ctx1.drawImage(this.babyBody, -this.babyBody.width*0.5, -this.babyBody.height*0.5); ? ?ctx1.drawImage(this.babyEye, -this.babyEye.width*0.5, -this.babyEye.height*0.5); ? ?ctx1.restore();}
舉報(bào)
學(xué)做HTML5游戲,輕輕松松帶你上手,適合剛?cè)胧钟螒蜷_(kāi)發(fā)的同學(xué)
1 回答??麤](méi)出來(lái)
1 回答??怀鰜?lái)怎么辦
2 回答關(guān)于海葵~
1 回答??该鞫?/p>
1 回答海葵畫(huà)不出
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-03-13
babyObj.prototype.draw = function () {
? ?// ctx1
? ?this.x = lerpDistance(mum.x, this.x, 0.98);
? ?this.y = lerpDistance(mum.y, this.y, 0.98);
? ?//delta angle
? ?var deltaY = mum.y - this.y;
? ?var deltaX = mum.x - this.x;
? ?var beta = Math.atan2(deltaY,deltaX) + Math.PI;
? ?this.angle = lerpAngle(beta,this.angle,0.6);
? ?ctx1.save();
? ?ctx1.translate(this.x, this.y);
? ?ctx1.rotate(this.angle);
? ?ctx1.drawImage(this.babyTail, -this.babyTail.width*0.5+23, -this.babyTail.height*0.5);
? ?ctx1.drawImage(this.babyBody, -this.babyBody.width*0.5, -this.babyBody.height*0.5);
? ?ctx1.drawImage(this.babyEye, -this.babyEye.width*0.5, -this.babyEye.height*0.5);
? ?ctx1.restore();
}