import flash.events.Event;
import flash.geom.Point;
stage.addEventListener (Event.ENTER_FRAME,enterframe);
function enterframe(e:Event):void{
arrow_mc.rotation=GetAngleOfLineBetweenTwoPoints(new Point(arrow_mc.x,arrow_mc.y),new Point(mouseX,mouseY));
}
function GetAngleOfLineBetweenTwoPoints(p1:Point, p2:Point):Number{
var xDiff:Number= p2.x - p1.x;
var yDiff:Number= p2.y - p1.y;
return Math.atan2(yDiff, xDiff)/Math.PI*180;
}
as3 angle between two point in 2d
2012年2月17日 星期五 by Hu, Ching-Hsiang
Filed under
having
0
意見
訂閱:
文章 (Atom)