快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

大炮打敌机小游戏(附源码)

  动画效果:

« Full Screen »

点击这里下载源文件

  主场景中ball的帧内容:

主场景中AS:

gun_mc._rotation=-40;
_root.ang=-40;
_root.total=0;
_root.attachMovie("fly","fly",10,{_x:random(300)+220,_y:random(220)+10});
up_btn.onPress=function(){
turnangle(5);
if(gun_mc._rotation<-85){
gun_mc._rotation=-85;
}
}
down_btn.onPress=function(){
turnangle(-5);
if(gun_mc._rotation>-5){
gun_mc._rotation=-5;
}
}
function turnangle(tmp){
gun_mc._rotation+=-1*tmp;
_root.ang=gun_mc._rotation;
}
fire_btn.onPress=function(){
if(_root.ball._currentframe==1){
_root.ball.gotoAndPlay(2);
}
}

//------------------------------------

ball中第一帧:
stop ();
_visible = false;

第二帧:
var rad = -_root.ang/180*Math.PI;
_x = _root.gun_mc._x+80*Math.cos(rad);
_y = _root.gun_mc._y-80*Math.sin(rad);
var Vx = Math.sqrt(750)*Math.cos(rad);
var Vy = -1*Math.sqrt(750)*Math.sin(rad);
_visible = true;

第三帧:
var hitMon = this.hitTest(_root.fly);
if (hitMon) {
gotoAndPlay("HitBang");
}
_x += Vx;
_y += Vy;
Vy++;
if (_y>=350 || _x>550) {
gotoAndPlay("Bang");
}
trace(1);

第四帧:
gotoAndPlay (_currentframe-1);

第16帧:
gotoAndStop(1);

第17 帧
:_root.fly.removeMovieClip();
_root.total++;

第26帧
:_root.attachMovie("fly", "fly", 10, {_x:random(300)+220, _y:random(220)+10});
gotoAndStop(1);
//------------------------------------------

你也可以试试.
返回类别: Flash教程
上一教程: Flash使用技巧--用Flash制作即指即现的广告条
下一教程: FLASH的编程习惯

您可以阅读与"大炮打敌机小游戏(附源码)"相关的教程:
· 判定数字大小(小游戏)制作过程
· Flash游戏制作常用代码解析(图)
· flash游戏杀狗大赛制作
· Flash游戏开发系列一:游戏中的敌人(5)
· Flash MX 2004实例制作视频教程:七巧板互动游戏(4)
    微笑服务 优质保证 索取样品