0

我有一个添加攻击影片剪辑的敌人。更具体地说,这个攻击影片(我们称之为masterAttack)剪辑是一个空白影片剪辑,它的作用就像一个超类,它将持有其他攻击,如弱攻击和强攻击。因此,当我的敌人使用计时器进行攻击时,它会将 masterAttack 添加到全局到本地点。

下面是敌人计时器攻击玩家所在的瓷砖:

if (Main.tileset[k].tileMiddle.hitTestObject(Main.player.visionPoint))
{
         this.addChild(masterAttack);
         var pt:Point = this.enemymagic.globalToLocal(new Point(Main.tileset[k].x, Main.tileset[k].y));
         masterAttack.masterEnemyAttackTimer.start();

         this.masterAttack.x = (pt.x);
         this.masterAttack.y = (pt.y);
}

下面是 masterAttack 计时器:

function mastertimer(event:TimerEvent) {
                    addChild(sludgeball); //This is one of the many attacks pickable by the masterAttack
                              sludgeball.enemyattackTimer.start();
                              if (this.sludgeball.currentLabel == "End") {
                                        this.sludgeball.gotoAndPlay(1);
                                        masterEnemyAttackTimer.stop();

                              if (masterEnemyAttackTimer.running == false)
                              {
                                        attackStop = true;
                                        this.parent.removeChild(this);
                                        removeChild(sludgeball);
                              }
                    }

我的问题是,在第一次运行时,masterAttack 会在任何地方攻击玩家,然后将自己移除,这很好。然后下一次运行时,masterAttack 并没有击中玩家。就好像 globaltoLocal 在第一次运行后不起作用。

4

1 回答 1

0
this.addChild(masterAttack);

var pt:Point = this.enemymagic.globalToLocal(new Point(Main.tileset[k].x, Main.tileset[k].y));

您将 masterAttack 添加到此,但使用enemymagic 的 globalToLocal 获得了 pt

所以像这样改变线

var pt:Point = this.globalToLocal(new Point(Main.tileset[k].x, Main.tileset[k].y));
于 2013-08-19T02:50:01.720 回答