指向鼠标指针的核心代码

      FLASH文摘 2004-12-24 2:2
//创建一个影片剪辑“y_mc”
onEnterFrame = function () {
vx = _xmouse-y_mc._x;

vy = _ymouse-y_mc._y;

digree = Math.atan(vy/vx)*180/Math.PI;

//“Math.atan(vy/vx)”得到弧度,“*180/Math.PI”转成度数。

//判断各种不同的情况,通过运算使digree值在0-360之间
    if (vy>=0 && vx>=0) {
        digree = digree;
    } else if (vx>=0 && vY<=0) {
        digree = 360+digree;
    } else {
        digree = 180+digree;
    }
y_mc._rotation = digree+90;//为什么要加90才能实现呢?谁能告诉我?
};


Flash 动画
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}