2012-03-23 81 views
0

我一直试图解决这个问题几个小时了,我无法弄清楚,无论我做什么。在我收集所有硬币后,游戏中的门户网站会被解锁。门户网站已被锁定,但当我浏览一枚硬币时,它既不会添加到变量中,也不会通过coin1 coin2和coin3的实例名称删除该影片剪辑。有人可以帮助我吗?Flash as2添加到一个变量,并删除一个影片剪辑

如果删除影片剪辑不需要_root我已经尝试过没有它我知道这不是问题。

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; 

回答

0

试试这个:

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; 
+0

感激这么多!我发布了openportal ++之后,我从未想过要有_root。在removemovieclip之前。 – 2012-03-25 12:56:27

相关问题