【问题标题】:Move an object in the direction its pointing Actionscript 3沿其指向的方向移动对象 Actionscript 3
【发布时间】:2014-10-08 10:38:02
【问题描述】:

我在 actionscript 3 中搞砸了,并试图移动一个对象,我可以让它移动,但只能在 y 轴上 我已经设置好了对象并旋转 我想要做的是将它朝它指向的方向移动,因此它不仅限于仅沿 y 或 x 轴移动

有人有什么建议吗?

【问题讨论】:

标签: actionscript-3 flash actionscript


【解决方案1】:

只需一些基本的三角函数就可以了。

var speed:Number = 10;
var angle:Number = Math.PI/2;

obj.x += speed * Math.cos(angle);
obj.y += speed * Math.sin(angle);

对于更高级的魔法,我建议学习线性代数。可以有一个好的开始here :)

【讨论】:

    猜你喜欢
    • 2017-01-11
    • 2023-04-05
    • 1970-01-01
    • 2013-01-04
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 2017-06-18
    • 1970-01-01
    相关资源
    最近更新 更多