Pergunta

I've been trying to solve this problem for hours now and i cannot figure it out no matter what I do. The portal in my game is suppose to be unlocked after you collect all the coins. The portal is locked but when I go over a coin it neither adds to the variable or removes the movie clip by instance name of coin1 coin2 and coin 3. Can someone please help me?

also if the remove movie clip doesnt need _root I've already tried it without it I know that is not the problem.

var openportal = 0;
function moveStuff() {
      //-Very long code that is working.    
}


if (ball_mc.hitTest(coin1._x, coin1._y)) {
    removeMovieClip(_root.coin1);
                var openportal = openportal + 1;
        }
        if (ball_mc.hitTest(coin2._x, coin2._y)) {
            removeMovieClip(_root.coin2);
                var openportal = openportal + 1;
        }
        if (ball_mc.hitTest(coin3._x, coin3._y)) {
            removeMovieClip(_root.coin3);
                var openportal = openportal + 1;
        }

        if (openportal >= 3){
           if (goal1_mc.hitTest(ball_mc._x, ball_mc._y)) {
                gotoAndStop(2);
           }
        }
ball_mc.onEnterFrame = moveStuff;
Foi útil?

Solução

try this :

var openportal = 0;
function moveStuff() {
      //-Very long code that is working.    
}

        if (ball_mc.hitTest(coin1._x, coin1._y)) {
            _root.removeMovieClip(coin1);
            openportal++;
        }
        if (ball_mc.hitTest(coin2._x, coin2._y)) {
            _root.removeMovieClip(coin2);
            openportal++;
        }
        if (ball_mc.hitTest(coin3._x, coin3._y)) {
            _root.removeMovieClip(coin3);
             openportal++;
        }

        if (openportal >= 3){
           if (goal1_mc.hitTest(ball_mc._x, ball_mc._y)) {
                gotoAndStop(2);
           }
        }
ball_mc.onEnterFrame = moveStuff;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top