帧一的动作
import flash.events.MouseEvent;
import flash.events.Event;
stop();
btn.addEventListener(MouseEvent.CLICK, btn_click);
function btn_click(event:Event):void{
gotoAndStop("fire");
}
帧二的动作
atartPlaneAir();
package{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.events.Event;
public class dafeiji extends MovieClip{
public function atartPlaneAir():void{
var gunO:AAGun=new AAGun();
gunO.x=275;
gunO.y=320;
addChild(gunO);
stage.addEventListener(KeyboardEvent.KEY_DOWN,fire);
addEventListener(Event.ENTER_FRAME, checks);
plane();
}
public function checks(event:Event):void{
for(var i:int=0;i<planeArr.length;i++){
if(planeArr[i].x>550){
planeface[i]="right";
planeArr[i].scaleX=1;
}
if(planeArr[i].x<0){
planeface[i]="left";
planeArr[i].scaleX=-1;
}
if(planeface[i]=="left"){
planeArr[i].x++;
}else{
planeArr[i].x--;
}
}
for(var j:int=0;j<bulletArr.length;j++){
bulletArr[j].y=bulletArr[j].y-3;
if(bulletArr[j].y<0){
removeChild(bulletArr[j]);
bulletArr.splice(j,1);
}
}
for(var p:int=0;p<planeArr.length;p++){
for(var q:int=0;q<bulletArr.length;q++){
if(planeArr[p] && planeArr[p].hitTestObject(bulletArr[q]))
{
planeArr[p].gotoAndPlay(6);
removeChild(bulletArr[q]);
planeArr.splice(p,1);
planeface.splice(p,1);
bulletArr.splice(q,1);
}
}
}
}
public var planeface:Array=new Array();
public var planeArr:Array=new Array();
public function plane():void{
var plane:Airplane=new Airplane();
plane.x=10;
plane.y=50;
plane.gotoAndStop(3);
addChild(plane);
planeArr.push(plane);
plane.scaleX = -1;
var plane1:Airplane=new Airplane();
plane1.x=500;
plane1.y=50;
plane1.gotoAndStop(4);
addChild(plane1);
planeArr.push(plane1);
plane1.scaleX = -1;
planeface.push("left");
planeface.push("left");
}
var bulletArr:Array=new Array();
//var bullet:Bullet=new Bullet();
public function fire(event:Event):void{
var bullet:Bullet=new Bullet();
bullet.x=275;
bullet.y=320;
addChild(bullet);
bulletArr.push(bullet);
}
}
}
具体项目见附件,(问题解决)有一点点错误提示,没时间解决了。。。。。。。。。