即時通訊工作在fps遊戲。遊戲包含多個敵人。但即時通訊與敵人相同的動畫片段。該movieclip發送火災事件,並減少玩家的生活。但我需要知道哪個movieclip正在調度事件。我隨機添加敵人,我需要知道剛剛開火的敵人的敵人位置。下面有一些代碼,可以幫助...as3如何跟蹤哪個movieclip正在調度事件
dispatchEvent(new Event('Enemy_Fired')); // this event is dispatching from enemy movieclip
this.addEventListener('Enemy_Fired',ReduceLife);
public function ReduceLife(e:Event){
life--;
var currentLife:int = life * lifeRatio;
if(life<1){
Game_Over();
//game_completed();
} else {
sview.playerhit.gotoAndPlay(2);
sview.lifebar.gotoAndStop(100 - currentLife);
sview.health.text = String(currentLife);
}
//Here i need to know this event dispatched from which enemy
}
在此先感謝
我之前檢查過,它顯示我的根類,我在哪裏捕捉事件,我需要從哪裏調度事件的動畫片... –
啊,我明白了,我更新了我的答案! – user1574041