Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何定位旋转的电影剪辑?_Actionscript 3_Flash_Rotation_Movieclip - Fatal编程技术网

Actionscript 3 如何定位旋转的电影剪辑?

Actionscript 3 如何定位旋转的电影剪辑?,actionscript-3,flash,rotation,movieclip,Actionscript 3,Flash,Rotation,Movieclip,如果不干扰旋转,就很容易相对于另一个精灵对象定位一个精灵对象。正如标题所述,我想知道如何相对于已经旋转的MC定位2个MC,以便它们彼此对齐。这枚大火箭呈35度角 首先,我将大火箭的角度设置为0度,我在舞台上添加两个小火箭,并将它们放置在大火箭的两侧。到现在为止,一直都还不错。。。我把所有的东西都旋转回初始角度(35度),但有些地方不对劲,正如你在pic1中看到的结果,我必须改变什么,以使两个小火箭保持完全对齐(一个在较大火箭的左侧,另一个在右侧)并旋转,如pic2 所有对象的注册点位于左上角 编

如果不干扰旋转,就很容易相对于另一个精灵对象定位一个精灵对象。正如标题所述,我想知道如何相对于已经旋转的MC定位2个MC,以便它们彼此对齐。这枚大火箭呈35度角 首先,我将大火箭的角度设置为0度,我在舞台上添加两个小火箭,并将它们放置在大火箭的两侧。到现在为止,一直都还不错。。。我把所有的东西都旋转回初始角度(35度),但有些地方不对劲,正如你在pic1中看到的结果,我必须改变什么,以使两个小火箭保持完全对齐(一个在较大火箭的左侧,另一个在右侧)并旋转,如pic2

所有对象的注册点位于左上角 编辑:两个小火箭必须位于较大的火箭容器外,因为它们最终将独立于容器设置动画


旋转后,尝试将左火箭和右火箭移动到正确的位置

这是代码移动

//the old left bottom point of rocketShip
var point1:Point= new Point(0, rocketShip.height);

//the old right-bottom poiny of leftship
var point2:Point = new point(_leftRocket.width, _leftRocket.height);

//the old right bottom point of rocketShip
var point5:Point= new Point(rocketShip.width, rocketShip.height);

//the old left-bottom point of rightship's 
var point6:Point = new point(0, _leftRocket.height);

//.. Your code


//get the new position of rocketship's left bottom point after rotation,leftShip's right bottom corner will be in this point
var point3:Point =  rocketShip.transform.matrix.transformPoint(point1);

//get the new  point of leftship's right-bottom-corner after rotation.
var point4:Point =  _leftRocket.transform.matrix.transformPoint(point2);

//move the leftShip
_leftRocket.x -= point4.x - point3.x;
_leftRocket.y -= point4.y - point3.y;
这是一艘合适的船

//get the new position of right bottom point  of rocketShip after rotation,rightShip's left bottom corner will be in this point
var point7:Point =  rocketShip.transform.matrix.transformPoint(point5);

//get the new  point of rightship's left-bottom-corner after rotation.
var point8:Point =  _rightRocket.transform.matrix.transformPoint(point6);

//move the rightShip
_rightRocket.x -= point8.x - point7.x;
_rightRocket.y -= point8.y - point7.y;
我认为你应该改变

 _rightRocket.y = rocketShip.x + _rightRocket.width;


如果你把注册点(枢轴)放在火箭的中心,那就容易多了。另一种方法是将火箭添加到一个容器电影剪辑中,然后旋转它。关于容器的事情,你是对的。但是对于动画效果来说,火箭必须在容器外,这一点非常重要。注册点的位置不是问题。我也试过了。同样的结果。不知道为什么你不能省去自己的头疼,把3个火箭放在一个容器中,然后旋转(你仍然可以在这个容器中分别设置它们的动画)。你能做的就是把所有的注册点放在同一个全球点上。然后它们会像在同一个容器中一样旋转。这个模拟是火箭进入轨道的简化。正如你们所知,太空火箭包括一个或多个一次性油箱,当燃料用完后,这些油箱会掉落,并在地球引力的作用下落回地球。当坦克与火箭分离时,我将它们的速度设置为0。使坦克在耳的重力作用下坠落的代码是基于牛顿第二定律的,但仍然没有。谢谢你抽出时间。我将按照Marjin和LDMediaServices所说的,轮换容器父容器。
 _rightRocket.y = rocketShip.x + _rightRocket.width;
 _rightRocket.x = rocketShip.x + rocketShip.width;