簡體   English   中英

addchild中的globaltoLocal

[英]globaltoLocal in addchild

我有一個敵人,該敵人添加了攻擊性影片剪輯。 更具體地說,此攻擊影片(我們將其稱為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無法正常工作。

this.addChild(masterAttack);

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

您將masterAttack添加到此,但是您使用敵方魔術師的globalToLocal獲得了pt

所以像這樣改變線

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM