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

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

动画效果:

主场景中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);

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

你也可以试试.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航