lundi 21 novembre 2016

How to have Movieclip Container position correctly?

Hello everyone so I am having a hard time trying to get this to work. Basically I have a Movie clip container called planetContainer which I add the MC in my array to like so:

private function collisionPlanetHandler():void 
    {
        for (var i:int = 0; i < aPlanetArray.length; i++)
        {
            var currentPlanet:mcOuterPlanets = aPlanetArray[i];

            planetContainer.addChild(aPlanetArray[i]);

            if (character.hitTestObject(currentPlanet) && !nextlevel)
            {
                trace("HIT");
                yDown += 300;
                //tap back to false
                tap = false;
                nextlevel = true;
                if (!bNullObject)  // have null object so doesnt loop again and cause error for planet == null
                {
                    planet.destroy();
                    planet =  null;
                }
                bNullObject = true;
                planetHit = currentPlanet; // to land on correct planet
                aPlanetArray.splice(i, 1);
                randomRotation = randomNumber(1, 2);  //Stop in random rotation for next planet

                TweenLite.to(planetContainer, 2.0, { y:(stage.stageHeight / 2) - 200, ease:Elastic.easeOut } );


                //planetIncrement -= 200;
                //addPlanet(randomNumber(50, 200), planetIncrement);

            }

        }

    }private function collisionPlanetHandler():void 
    {
        for (var i:int = 0; i < aPlanetArray.length; i++)
        {
            var currentPlanet:mcOuterPlanets = aPlanetArray[i];

            planetContainer.addChild(aPlanetArray[i]); //add to container

            if (character.hitTestObject(currentPlanet) && !nextlevel)
            {
                trace("HIT");
                yDown += 300;
                //tap back to false
                tap = false;
                nextlevel = true;
                if (!bNullObject)  // have null object so doesnt loop again and cause error for planet == null
                {
                    planet.destroy();
                    planet =  null;
                }
                bNullObject = true;
                planetHit = currentPlanet; // to land on correct planet
                aPlanetArray.splice(i, 1);
                randomRotation = randomNumber(1, 2);  //Stop in random rotation for next planet

                TweenLite.to(planetContainer, 2.0, { y:(stage.stageHeight / 2) - 200, ease:Elastic.easeOut } );


                //planetIncrement -= 200;
                //addPlanet(randomNumber(50, 200), planetIncrement);

            }

        }

    }

as you can sort of see in that function when the player hits one of the planets in the array I want the planetContainer to tween down. But what I am trying to accomplish is when the player hits one of the MC in the array I want the container to tween down to the original position that they player was at which in this case is the center of the stage.

This is not doing what I thought it would:

 TweenLite.to(planetContainer, 2.0, { y:(stage.stageHeight / 2) - 200, ease:Elastic.easeOut } );

I know it is having the whole container center and whenever I try to land on another planet in the container nothing happens basically nothing moves down anymore. I don't know how to position the container to the last position of the player on the stage. Or how to have the planet it landed on position in the correct y axis which is center of stage y axis and then have the other planets fall down as well.

I hope I am making sense. If more information is needed I will provide it. Thank you!

Aucun commentaire:

Enregistrer un commentaire