我试图让flash从舞台中心画出一条线,并在舞台周围增加。不知道我会用什么数学来做这个。到目前为止,我已经走到某一点,但不知道如何改变这一点,以便它围绕我的舞台的尺寸旋转。
到目前为止,我有这个:
var linetox=0;
var linetoy=0;
var _stage=this;
var _stage_center_x = stage.stageWidth/2;
var _stage_center_y = stage.stageHeight/2;
trace(_stage_center_x);
function enterframe(e:Event):void {
linetox+=10;
linetoy+=10;
var lineDrawing:MovieClip = new MovieClip();
this.addChild(lineDrawing);
lineDrawing.graphics.lineStyle(1);
lineDrawing.graphics.moveTo(_stage_center_x,_stage_center_y);///This is where we start drawing
lineDrawing.graphics.lineTo(linetox, linetoy);
}
this.addEventListener(Event.ENTER_FRAME, enterframe);
这显然会使行的目标结尾越来越低,只是试图让它在屏幕上绘制(就像一个时钟)
答案 0 :(得分:1)
var center:Point = new Point(stage.stageWidth/2, stage.stageHeight/2);
var radius:Number = 200;
this.graphics.lineStyle(1, 0x000000, 1);
addEventListener(Event.ENTER_FRAME, drawCirc);
var _x:Number;
var _y:Number;
var _angle = -180;
var _rads = 0;
var rad_conversion:Number = Math.PI / 180;
function drawCirc($evt:Event) {
_rads = _angle * rad_conversion;
_x = radius * Math.cos(_rads) + center.x;
_y = radius * Math.sin(_rads) + center.y;
if (_angle == -180) {
this.graphics.moveTo(_x, _y);
} else {
this.graphics.lineTo(_x, _y);
}
_angle ++;
if (_angle >= 181) {
removeEventListener(Event.ENTER_FRAME, drawCirc);
}
}