Actionscript 翻译转换

发布于 2024-07-24 22:00:13 字数 296 浏览 4 评论 0原文

您好,我正在开发 ActionScript 3,我必须使用平移旋转缩放到影片剪辑。 我的旋转和缩放工作正常,但是当我处理平移时,我发现平移会将对象移动到原点之外的问题,因此当我想旋转对象时,对象不再按预期旋转。 实现翻译的最佳方法是什么,以便在翻译原点的同时翻译影片剪辑....

最后一件事.. movieclip.scale 和 movieclip.transform.scale 函数有什么区别? 如果我使用 movieclip.scale,我仍然可以从 movieclip.scale 获取 movieclip.transform.matrix

Hi I am working on actionscript 3 which I have to use translation rotation scaling to a movieclip. I have the rotation and scaling working properly but when I dealing with translation I find the problem that the translation will move the object outside of the origin so when I wanted to rotate the object, the object no longer rotate as expected. What is the best way to implement the translation so that it translate the movieclip while translate the origin....

Last thing.. What is the difference between movieclip.scale and movieclip.transform.scale function? If i use movieclip.scale, do I still able to get the movieclip.transform.matrix from that movieclip.scale

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

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

发布评论

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

评论(1

鲸落 2024-07-31 22:00:13

所有矩阵变换(包括旋转和缩放)均相对于剪辑所在坐标系的原点生效。 如果要围绕任何其他点旋转或缩放,则应将剪辑平移到该点,进行变换,然后再平移回来。 换句话说,这个:

clip.rotation = 30;

与这个: 做同样的事情:

var tx:Number = clip.x;
var ty:Number = clip.y;
var m:Matrix = clip.transform.matrix;
m.translate( -tx, -ty );
m.rotate(30*Math.PI/180);
m.translate( tx, ty );
clip.transform.matrix = m;

它的工作方式与比例变换完全相同。

对于您的另一个问题,MovieClip.scaleX/Y 和 Matrix.scale 之间的区别与旋转完全相同 - 您可以以任何一种方式应用旋转,但使用内置的 MC 属性,它们相对于剪辑的注册点生效,矩阵函数是相对于原点的。 如果剪辑的注册点位于 (0,0),则它们的工作方式相同。

All matrix transformations, including rotation and scale, take effect relative to the origin of the co-ordinate system where the clip lives. If you want to rotate or scale around any other point, you should translate the clip to that point, transform, and translate back. In other words, this:

clip.rotation = 30;

does the same thing as this:

var tx:Number = clip.x;
var ty:Number = clip.y;
var m:Matrix = clip.transform.matrix;
m.translate( -tx, -ty );
m.rotate(30*Math.PI/180);
m.translate( tx, ty );
clip.transform.matrix = m;

It works exactly the same way with scale transformation.

For your other question, the difference between MovieClip.scaleX/Y and Matrix.scale is exactly the same as with rotate - you can apply your rotations either way, but with the built in MC properties they take effect relative to the clip's registration point, and the Matrix functions are relative to the origin. If the clip's registration point is at (0,0) then they work the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文