呼啦啦巴扎嘿
2016-07-30 22:12
main.js里面和鼠标相关的:
can1.addEventListener('mousemove', onMouseMove, false);
function onMouseMove(e)
{
if(e.offsetX || e.layerX)
{
mx = e.offsetX == undefined ? e.layerX : e.offsetX;
my = e.offsetY == undefined ? e.layerY : e.offsetY;
}
}
mom.js里面:
momObj.prototype.draw = function()
{
this.x = lerpDistance(mx, this.x, 0.98);
this.y = lerpDistance(my, this.y, 0.98);
var deltaY = my - this.y;
var deltaX = mx - this.x;
var beta = Math.atan2(deltaY, deltaX);
this.angle = lerpAngle(beta, this.angle, 0.6);
ctx1.save();
ctx1.translate(this.x, this.y);
ctx1.rotate(this.angle);
ctx1.drawImage(this.bigEye, -this.bigEye.width * 0.5, -this.bigEye.height * 0.5);
ctx1.drawImage(this.bigBody, -this.bigBody.width * 0.5, -this.bigBody.height * 0.5);
ctx1.drawImage(this.bigTail,-this.bigTail.width * 0.5 + 30, -this.bigTail.height * 0.5);
ctx1.restore();
}
我也是这样 你解决了没啊
很大是什么鬼?我看了一下代码和我的就是这里不一样
var beta = Math.atan2(deltaY,deltaX) + Math.PI;
HTML5小游戏---爱心鱼(上)
92350 学习 · 551 问题
相似问题