0
它们并不是真正的敌人,它们只是你射击的气球。但是,当他们添加addChild时,他们都没有在播放他们的“死亡”动画,当我点击(拍摄)他们。这是我的代码。请原谅,如果它显得杂乱无章,我刚开始没有OOP经验的ActionScript。杀死游戏敌人ActionScript 3.0
一切正常,除了点击儿童似乎根本没有注册添加到舞台上的对象。我没有外部类,所有实例名都是正确的。我把联系中的气球称为“受害者”。
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.MouseEvent;
Mouse.hide();
cursor_mc.startDrag(true);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
shotHandler.addEventListener(MouseEvent.MOUSE_DOWN, boxShot);
function boxShot(evt:MouseEvent):void
{
enemyBox.gotoAndStop(2);
}
function onClick(event:MouseEvent):void
{
cursor_mc.play();
var myBullet:MovieClip = new black_mc();
myBullet.x = mouseX; myBullet.y = mouseY;
stage.addChildAt(myBullet , 0);
}
var myTimer:Timer = new Timer(1200, 300);
myTimer.addEventListener(TimerEvent.TIMER, createEnemies);
myTimer.start();
function createEnemies(e:Event):void
{
var circle:MovieClip = new victim();
circle.x = Math.random() * stage.stageWidth;
circle.y = Math.random() * stage.stageHeight;
addChildAt(circle , 2);
}