【问题标题】:AS3: Rotation into VectorAS3:旋转成向量
【发布时间】:2012-08-18 06:00:18
【问题描述】:

嘿,我在 actionscript3 中旋转位图,完成旋转后我想更新方向,所以我存储了位图旋转的度数,例如旋转 = 90°,现在我想将其转换为矢量(x,y) 来确定对象现在面向的方向

提前谢谢

【问题讨论】:

    标签: actionscript-3 vector bitmap rotation


    【解决方案1】:

    你可以这样做,使用三角函数:

    //convert degrees to rads
    var rads:Number = bitmap.rotation / 180 * Math.PI;
    //get the vector, I am using a point
    var p:Point = new Point();
    p.x = Math.cos(rads);
    p.y = Math.sin(rads);
    

    现在,如果您想将位图移动到某个方向,您只需执行以下操作:

    bitmap.x += p.x * speed;
    bitmap.y += p.y * speed;
    

    【讨论】:

    • 非常感谢 =D 以为我可以轻松使用高中数学,但似乎有点太长了^^
    猜你喜欢
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    • 1970-01-01
    • 2016-10-25
    • 1970-01-01
    • 2011-08-29
    相关资源
    最近更新 更多