毕业论文 论文提纲 论文写作 公文范例 教育论文 教育学论文 师范教育 学术论文     论文指导*
                     
 
   
   
   
   
           
 

当前位置:课件115学培吧(kj115.com)→FLASH课件游戏开发教程→文章系列

 
 
标题:学习Flash制作高射炮游戏
 
展示台

文章来源 作者:admin 密码:admin 整理:湖北金鹰

◇游戏开发栏目简介
内容是FLASH课件游戏制作教程,适合开发课件游戏,增加课件的感染力,适合高手学习,基础学习者可以参加我站的游戏开发视频教程的学习是最佳之选。

其它教程文章还有网侠教程图文教程等。
学习过程中如果需要相关的软件下载,你可以到本站软件下载专区去看看。

---------------

论文相关服务
 

湖北金鹰课件吧

主要是利用FlashActionscript一步一步学习Flash高射炮简单游戏的制作过程,最终效果只是一个简单的演示,如果你有兴趣可以继续深入学习!(教程最后页提供演示动画的源程序下载)
第一步:首先简单的制作一个鼠标动画,绘制一个鼠标的图,自己定。然后选择第一帧输入下面代码:
Mouse.hide();
attachMovie("crosshair","crosshair",1);
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
第二步:绘制一个坦克,分成两部分,如下面:

Flash制作高射炮游戏

绘制坦克
把下面的命名实例名为tank。代码如下:
Mouse.hide();
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:230,_y:350});
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
tank.onEnterFrame=function(){
mousex=_xmouse-this._x;
mousey=(_ymouse-this._y)*-1;
angle=Math.atan(mousey/mousex)/(Math.PI/180);
if(mousex<0){
angle+=180;
}
if(mousex>=0&&mousey<0){
angle+=360;
}
this.cannon._rotation=angle*-1;
};

第三步:我这里设置转动的一定的角度。

Mouse.hide();
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:230,_y:350});
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
tank.onEnterFrame=function(){
mousex=_xmouse-this._x;
mousey=(_ymouse-this._y)*-1;
angle=Math.atan(mousey/mousex)/(Math.PI/180);
if(mousex<0){
angle+=180;
}
if(mousex>=0&&mousey<0){
angle+=360;
}
if(angle>160){
angle=160;
}
if(angle<20){
angle=20;
}
this.cannon._rotation=angle*-1;
};

然后是计算开火的目标:

Mouse.hide();
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:230,_y:350});
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
tank.onEnterFrame=function(){
mousex=_xmouse-this._x;
mousey=(_ymouse-this._y)*-1;
angle=Math.atan(mousey/mousex)/(Math.PI/180);
if(mousex<0){
angle+=180;
}
if(mousex>=0&&mousey<0){
angle+=360;
}
if(angle>160){
angle=160;
}
if(angle<20){
angle=20;
}
firepower=Math.sqrt(mousex*mousex+mousey*mousey);
if(firepower>200){
firepower=200;
}
this.cannon._rotation=angle*-1;
};
开火的制作:
Mouse.hide();
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:230,_y:350});
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
tank.onEnterFrame=function(){
mousex=_xmouse-this._x;
mousey=(_ymouse-this._y)*-1;
angle=Math.atan(mousey/mousex)/(Math.PI/180);
if(mousex<0){
angle+=180;
}
if(mousex>=0&&mousey<0){
angle+=360;
}
if(angle>160){
angle=160;
}
if(angle<20){
angle=20;
}
firepower=Math.sqrt(mousex*mousex+mousey*mousey);
if(firepower>200){
firepower=200;
}
this.cannon._rotation=angle*-1;
};
functiononMouseDown(){
angle=tank.cannon._rotation-1
start_ball_x=tank._x+48*Math.cos(angle*Math.PI/180);
start_ball_y=tank._y+48*Math.sin(angle*Math.PI/180);
attachMovie("cannonball","cannonball",3,{_x:start_ball_x,_y:start_ball_y});
}
开火出来炮弹:
Mouse.hide();
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:230,_y:350});
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
tank.onEnterFrame=function(){
mousex=_xmouse-this._x;
mousey=(_ymouse-this._y)*-1;
angle=Math.atan(mousey/mousex)/(Math.PI/180);
if(mousex<0){
angle+=180;
}
if(mousex>=0&&mousey<0){
angle+=360;
}
if(angle>160){
angle=160;
}
if(angle<20){
angle=20;
}
firepower=Math.sqrt(mousex*mousex+mousey*mousey);
if(firepower>200){
firepower=200;
}
this.cannon._rotation=angle*-1;
};
functiononMouseDown(){
angle=tank.cannon._rotation-1;
start_ball_x=tank._x+48*Math.cos(angle*Math.PI/180);
start_ball_y=tank._y+48*Math.sin(angle*Math.PI/180);
cannonball_fired=attachMovie("cannonball","cannonball_"+_root.getNextHighestDepth(),_root.getNextHighestDepth(),{_x:start_ball_x,_y:start_ball_y});
cannonball_fired.dirx=Math.cos(angle*Math.PI/180)*firepower;
cannonball_fired.diry=Math.sin(angle*Math.PI/180)*firepower;
cannonball_fired.onEnterFrame=function(){
this._x+=this.dirx/50;
this._y+=this.diry/50;
};
}
最后再加以详细的限制一下炮弹:
Mouse.hide();
gravity=2;
attachMovie("crosshair","crosshair",1);
attachMovie("tank","tank",2,{_x:230,_y:350});
crosshair.onEnterFrame=function(){
this._x=_xmouse;
this._y=_ymouse;
};
tank.onEnterFrame=function(){
mousex=_xmouse-this._x;
mousey=(_ymouse-this._y)*-1;
angle=Math.atan(mousey/mousex)/(Math.PI/180);
if(mousex<0){
angle+=180;
}
if(mousex>=0&&mousey<0){
angle+=360;
}
if(angle>160){
angle=160;
}
if(angle<20){
angle=20;
}
firepower=Math.sqrt(mousex*mousex+mousey*mousey);
if(firepower>200){
firepower=200;
}
this.cannon._rotation=angle*-1;
};
functiononMouseDown(){
angle=tank.cannon._rotation-1;
start_ball_x=tank._x+48*Math.cos(angle*Math.PI/180);
start_ball_y=tank._y+48*Math.sin(angle*Math.PI/180);
cannonball_fired=attachMovie("cannonball","cannonball_"+_root.getNextHighestDepth(),_root.getNextHighestDepth(),{_x:start_ball_x,_y:start_ball_y});
cannonball_fired.dirx=Math.cos(angle*Math.PI/180)*firepower;
cannonball_fired.diry=Math.sin(angle*Math.PI/180)*firepower;
cannonball_fired.onEnterFrame=function(){
this.diry+=gravity;
this._x+=this.dirx/50;
this._y+=this.diry/50;
};
}

 

 
课件115学培吧(湖北金鹰)欢迎您!永久免费服务网址:http://www.kj115.com
   
 

学员众多的FLASH课件学习基地,成万免费FLASH课件制作教程在线学习,还有免费内容课件教程、视频教程、课件技巧、课件探讨、课件欣赏、课件展示、实用教程、课件界面、课件脚本、课件游戏、课件下载、课件封面、课文内容图片、课文人物图片库、课件素材、图片素材、声音素材、动物素材、背景图片、背景资料、背景边框、课件顶栏图片素材、Dreamweaver教程、Dreamweaver网页课件教程、软件下载。承接学习和培训,承接课件订制,课件修改等所有课件相关服务。
本站主要业务:┃flash课件制作视频教程培训┃承接全国竞赛flash课件┃论文代写代发┃代办课件国家级获奖证书┃
联系:QQ:444860709 手机:13339817386


 
 

业务办理
鄂ICP备08005724号