我有个敌人加了一段攻击性的电影。更具体地说,这个攻击电影(我们称之为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在第一次运行后就不工作了。
发布于 2013-08-19 10:50:02
this.addChild(masterAttack);
var pt:Point = this.enemymagic.globalToLocal(new Point(Main.tileset[k].x, Main.tileset[k].y));您将masterAttack添加到其中,但您使用enemymagic获得了pt
所以把这行改成这样
var pt:Point = this.globalToLocal(new Point(Main.tileset[k].x, Main.tileset[k].y));https://stackoverflow.com/questions/18304545
复制相似问题