如何 tweenLite 数组中的所有对象并保持距离位置?

How to tweenLite all objects in array and keep distance position?

大家好,我有一个名为 aPlanetArray 的影片剪辑对象数组,我想要完成的是让数组中的所有对象向下移动到某个位置,然后停止使用 tweenLite 或任何其他方法可以做到这一点。我知道我可以使用 y+=2 来做到这一点,但我希望所有对象都在使用 Tweenlite 的弹跳效果中真正快速地沿着屏幕向下移动并保持它们的距离比。

这是我将它们添加到舞台时的设置方式:

//Numbers
        xSpacing = 100;
        ySpacing = 180;
        startPoint = new Point((stage.stageWidth / 2), (stage.stageHeight / 2) );

private function addOuterPlanets():void 
    {
        for (var i:int = 0; i < nPlanets; i++)
        {
            outerPlanets = new mcOuterPlanets();
            outerPlanets.x = startPoint.x + (xSpacing * i);
            outerPlanets.y = startPoint.y - (ySpacing * i);
            stage.addChild(outerPlanets);
            aPlanetArray.push(outerPlanets);

        }
    }

当我对它们进行补间时,我使用的是这个 tweenlite 函数:

for each(var allPlanets:mcOuterPlanets in aPlanetArray)
                {
                    TweenLite.to(allPlanets, 5.0, {y:550, ease:Back.easeOut});
                }

这很完美,但阵列中的所有对象都排在一起并且彼此之间没有保持间距。如有任何想法,我们将不胜感激!

最简单的方法是将所有行星放在父容器中,然后移动容器而不是行星。

var planetContainer:Sprite = new Sprite();

function addPlanetsToContainer():void{
    for (var i:int = 0; i < aPlanetArray.length; i++){
        planetContainer.addChild(aPlanetArray[i]);
    }
}

现在您可以在 planetContainer

上进行补间了

现在要将角色放在行星上,您可以执行

planet.addChild(character);

character.x = planet.x + planet.parent.x;
character.y = planet.y + planet.parent.y;