AS3 绕舞台

发布于 2024-08-20 06:43:26 字数 737 浏览 4 评论 0原文

我试图让闪光灯从舞台中心画一条线并围绕舞台递增。但不确定我会用什么数学来做到这一点。到目前为止,我已经将线延伸到某个点,但不确定如何更改该点,以便它围绕我的舞台尺寸旋转。

到目前为止,我有这个:

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);

这显然将线的目标结尾移动得越来越低,只是试图让它在屏幕上绘制(就像时钟一样)

I am trying to have flash draw a line from the center of the stage out and increment around the stage. Not sure what math I would use to do this though. So far I have the line going out to a certain point but not sure how to change that point so that it circles around whatever the dimensions of my stage would be.

So far I have this:

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);

which obviously moves the destination ending of the line lower and lower, just trying to get it to draw around the screen (like a clock)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

(り薆情海 2024-08-27 06:43:26
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);
    }
}
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);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文