function mouseclickHandler(e:Event):void {
shootBullet();
}
function shootBullet() {
var bullet:MovieClip = new Bullet();
bullet.x = Ship.x;
bullet.y = Ship.y;
addChild(bullet);
bullet.addEventListener(Event.ENTER_FRAME,moveBullet);
}
function moveBullet(e:Event):void {
e.target.y -= 5;
if (e.target.y <= -10) {
e.target.removeEventListener(Event.ENTER_FRAME, moveBullet);
removeChild(MovieClip(e.target));
}
}
function keydownHandler(e:KeyboardEvent):void{
if (e.keyCode == Keyboard.SPACE) {
shootBullet();
}
}
stage.addEventListener(Event.ENTER_FRAME, checkhit);
function checkhit(myevent:Event) :void {
for (var i:int = 0; i < 15; i++) {
if (blockArray[i].hitTestPoint(mouseX,mouseY,true)) {
blockArray[i].alpha=.3;
Ship.play();
}
No comments:
Post a Comment