2013-05-14 65 views
0

你好,我正在使用Flash AS2制作一个简单的游戏,我不知道如何从舞台上移除一个物体。为什么我的物品不能从舞台上移开? AS2

我有所谓的“敌人”具有以下代码的简单对象:

onClipEvent(enterFrame) { 
      if (hitTest(_root.charBoy)) _root.life--; 
      function remove() { 
      this.removeMovieClip();  
      } 
    } 

我再尝试调用remove功能时,我的“子弹”物碰撞这样的:

if (hitTest(_root.Enemy)) 
    { 
     _root[Enemy].remove(); 
     this.removeMovieClip(); 
    } 

但是唯一发生的是只有子弹对象被移除,敌人AI停留在舞台上。

我自己也尝试在声明函数以下变化:

onClipEvent(load) 
{ 
    function remove() 
    { 
     this.removeMovieClip(); 
    } 
    remove(); 
} 
onClipEvent(enterFrame) { 
    if (hitTest(_root.charBoy)) _root.life--; 
} 

onClipEvent(enterFrame) { 
    if (hitTest(_root.charBoy)) _root.life--; 
    function remove() 
    { 
     this.removeMovieClip(); 
    } 
    remove(); 
} 

仍然做同样的事情。我也试过stage.removeChild(this),但它什么也没做。

请告诉我如何解决这个问题,我已经在舞台上设置了敌人,并有简单的AI动作,而不是以编程方式复制它们。

当我的Bullet碰到某个物体时,我该如何将它们从舞台上移开。

我的Bullet对象已经可以跟踪它们并且hits它们使得Bullet本身从舞台上移除,但敌方物体仍然存在。

+0

这看起来像AS2,AS3不按照建议。 – 2013-05-14 17:47:19

+0

'if(hitTest(_root.Enemy)) { _root.Enemy.remove(); this.removeMovieClip(); }' – RST 2013-05-14 19:18:19

回答

0

周围 '敌'

_root["Enemy"].remove(); 

报价试试以上

_root.Enemy.remove(); 
相关问题