我在 as3 中制作了一款横向卷轴游戏,玩家生成的单位会自动走向屏幕另一侧的出口,但有塔楼阻止它们。我想把塔分开拍,有什么办法吗?这是我的代码,一旦满足 if 语句,所有塔将同时触发。
private function tower1Fire():void
{
for (var j:int = creep1Array.length - 1; j >= 0; j--)
{
for each (var towerOne:mcTower1 in tower1Array)
{
if (creep1Array[j].x - towerOne.x <= 100 && creep1Array[j].y > towerOne.y)
{
var newTower1Bullet:mcLaser1 = new mcLaser1;
newTower1Bullet.x = towerOne.x;
newTower1Bullet.y = towerOne.y;
tower1BulletArray.push(newTower1Bullet);
stage.addChild(newTower1Bullet);
}
}
}
}
我在屏幕上有 3 个塔,使用以下代码添加:
var tower1New1:MovieClip = new mcTower1;
tower1New1.x = 313;
tower1New1.y = 340;
tower1Array.push(tower1New1);
MovieClip(root).addChild(tower1New1);
我没有收到任何错误。任何回复将不胜感激,谢谢!