課程
/前端開發
/HTML/CSS
/HTML5小游戲---愛心魚(上)
??趺礇]動
2017-01-13
源自:HTML5小游戲---愛心魚(上) 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();}
舉報
學做HTML5游戲,輕輕松松帶你上手,適合剛入手游戲開發的同學
1 回答海葵沒出來
1 回答??怀鰜碓趺崔k
2 回答關于海葵~
2 回答??嫴怀?/p>
5 回答??伙@示
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
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();
}