Flash:将影片剪辑从一个容器移动到另一个容器,同时保持相同的位置和旋转
如标题所示,我有 2 个容器 MovieClip(mc1、mc2),每个容器都有单独的 x、y 旋转。我想从 mc1 中获取一个子项,然后将其 addChild() 到 mc2,同时在屏幕上保持相同的 x、y 和旋转,这样您就可以看到添加的子 mc,就好像它没有更改位置或旋转,只是移动到另一个 MC 。知道怎么做吗?
As the title shows, I have 2 container MovieClips (mc1, mc2), each of them has a separate x,y, rotation. I want to take a child from mc1 and addChild() it to mc2 while keeping the same x, y, and rotation on the screen so you see the added child mc as if it didnt change position or rotation, just moved to the other MC. Any idea how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许这段代码可以帮助你:
您可以指定要转换为另一个影片剪辑的坐标系的点。
如果有多个单独旋转的子影片剪辑,问题仍然存在。否则,您可以仅使用已应用于影片剪辑的一次旋转,并将其应用于新的包装剪辑。
Maybe this piece of code might help you out:
You can specify a point which you want to translate into the coordinate system of another movie clip.
The problem remains, if there are multiple sub-movieclips, that are rotated individually. Otherwise you can use just the one rotation you have applied to the movieclip, and apply it to a new wrapper-clip.
您可以使用
localToGlobal()
和globalToLocal()
来实现这一点。编辑:
但是,这将无法正确处理旋转。因此,您可能需要在此之后旋转
child
以纠正mc1
和mc2
的旋转。由于它们处于同一级别,您可能应该根据它们各自旋转之间的差异来旋转child
。编辑:
从您在下面发布的代码:
You can use
localToGlobal()
andglobalToLocal()
to achieve that.Edit:
However, this will not handle the rotation correctly. So you will probably have to rotate
child
after that to correct for the rotation ofmc1
andmc2
. As they are in the same level, you should probably rotatechild
by the difference between their respective rotations.Edit:
From the code you posted below:
如果你有深层嵌套的转换,我会使用这样的东西。例如,您有嵌套精灵
mc1.mc2.mc3
,并且想要将mc3
重新附加到mc4
。这个看起来一个坐标系中的右向量 (1, 0) 与另一坐标系中的相同向量有多少不同。如果任何精灵被缩放,则必须进行修改
If you got deeply nested transforms I'd use something like this. For example you have nested sprites
mc1.mc2.mc3
and you want to reattachmc3
tomc4
. This one looks how much the right vector (1, 0) in one coordinate system differs from same vector in another one.Have to be modified if any of the sprites are scaled