1) 向某点旋转:
dx = mouseX - sprite.x;
dy = mouseY - sprite.y;
sprite.rotation = Math.atan2(dy,dx) * 180 / Math.PI;
2) 创建波形:
public function onEnterFrame(event:Event){
value = center + Math.sin(angle) * range;
angle += speed;
}
3) 创建圆形:
public function onEnterFrame(event:Event){
xposition = centerX + Math.cos(angle) * radius;
yposition = centerY + Math.sin(angle) * radius;
angle += speed;
}
4) 创建椭圆:
public function onEnterFrame(event:Event){
xposition = centerX + Math.cos(angle) * radiusX;
yposition = centerY + Math.sin(angle) * radiusY;
angle += speed;
}
5) 计算两点间距离:
dx = x2 - x1;
dy = y2 - y1;
dist = Math.sqrt(dx*dx + dy*dy);