유도탄의 추적관련
var dx = mouseX - arrow.x;
var dy = mouseY - arrow.y;
var radian = Math.atan2(dy,dx);
arrow.vx = Math.cos(radian)*speed;
arrow.vy = Math.sin(radian)*speed;
arrow.x += arrow.vx;
arrow.y += arrow.vy;
arrow.rotation = radian * 180/Math.PI;
마우스 포인트와의 충돌체크는
arrows[i].hitTestPoint(mouseX,mouseY,true) 를 이용.
|