我正在做一个 fps 游戏。游戏包含多个敌人。但我称同一个电影剪辑为敌人。该movieclip 会发送fire 事件并减少玩家生命。但我需要知道哪个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
}
提前致谢