今天整理文件的时候,发现自己以前有些做过的东西都快被自己遗忘了,挑了个有用的,
发给大家看看。
这个效果做了是一种飞机的子弹效果,1945里的BF-109蓄力子弹动态效果就是这样的,
不过它还加上了颜色效果。
效果是这样的,由于是开学时做的,用的还是AS1,大家随便看看了~~~算法还有点小用。
看效果先,按数字键0激发:
点击浏览该文件
把这种子弹做定帧播放效果应该是这样的:
帧一:
| |
||
| |
||
| |
帧二
||
| |
||
| |
||
帧三(重复帧一)
| |
||
| |
||
| |
所以,只要在左右两边各复制出一排子弹,按上面这种位置进行变化即可。
//子弹起名bullet
//飞机起名smallplane
_root.onLoad=function(){
templ=2.5;
tempr=-2.5;
L=-7.5;
R=7.5;
initialize=false;
starts=false
speed=3;
bullet._visible=false;
}
a=new Object();
Key.addListener(a);
a.onKeyDown=function(){//按数字键0激发动作.
if(Key.isDown(96)){initialize=true;}
}
function initializebullet_L(){//初始化左路的子弹。
L+=smallplane._x;//左路起始位置初始
for(var i=1;i<=11;i++){
bullet.duplicateMovieClip("bulletl"+i,i+50);//复制,设位.
eval("bulletl"+i)._y=smallplane._y-18-i*eval("bulletl"+i)._height;
eval("bulletl"+i)._x=L+templ;
templ*=-1;//交错就拿这个变理来做啦
}
L=-7.5;
}
function initializebullet_R(){//右路
R+=smallplane._x;
for(var j=1;j<11;j++){
bullet.duplicateMovieClip("bulletr"+j,j+60);
eval("bulletr"+j)._y=smallplane._y-18-j*eval("bulletr"+j)._height;
eval("bulletr"+j)._x=R+tempr;
tempr*=-1;
}
R=7.5;
}
function Motion(){//和上面初始化的思路差不多,只不过放在一起做了。
L+=smallplane._x;
R+=smallplane._x;
while(i<=11&&j<=11){
eval("bulletl"+i)._y=smallplane._y-18-i*eval("bulletl"+i)._height;
eval("bulletr"+j)._y=smallplane._y-18-j*eval("bulletr"+j)._height;
eval("bulletl"+i)._x=L+templ;
eval("bulletr"+j)._x=R+tempr;
templ*=-1;
tempr*=-1;
i++;j++;
}
templ*=-1;
L=-7.5;
R=7.5;
}
_root.onEnterFrame=function(){//先初始后再做动画,按数字键0激发.
if(initialize){initializebullet_L();initializebullet_R();initialize=false;starts=true;}
if(initialize==false&&starts==true){
Motion();
//trace(templ);
}
if( Key.isDown(Key.LEFT))smallplane._x -= speed;
if( Key.isDown(Key.RIGHT))smallplane._x += speed;
if( Key.isDown(Key.UP))smallplane._y -= speed;
if( Key.isDown(Key.DOWN))smallplane._y += speed;
}
//飞机起名smallplane
_root.onLoad=function(){
templ=2.5;
tempr=-2.5;
L=-7.5;
R=7.5;
initialize=false;
starts=false
speed=3;
bullet._visible=false;
}
a=new Object();
Key.addListener(a);
a.onKeyDown=function(){//按数字键0激发动作.
if(Key.isDown(96)){initialize=true;}
}
function initializebullet_L(){//初始化左路的子弹。
L+=smallplane._x;//左路起始位置初始
for(var i=1;i<=11;i++){
bullet.duplicateMovieClip("bulletl"+i,i+50);//复制,设位.
eval("bulletl"+i)._y=smallplane._y-18-i*eval("bulletl"+i)._height;
eval("bulletl"+i)._x=L+templ;
templ*=-1;//交错就拿这个变理来做啦
}
L=-7.5;
}
function initializebullet_R(){//右路
R+=smallplane._x;
for(var j=1;j<11;j++){
bullet.duplicateMovieClip("bulletr"+j,j+60);
eval("bulletr"+j)._y=smallplane._y-18-j*eval("bulletr"+j)._height;
eval("bulletr"+j)._x=R+tempr;
tempr*=-1;
}
R=7.5;
}
function Motion(){//和上面初始化的思路差不多,只不过放在一起做了。
L+=smallplane._x;
R+=smallplane._x;
while(i<=11&&j<=11){
eval("bulletl"+i)._y=smallplane._y-18-i*eval("bulletl"+i)._height;
eval("bulletr"+j)._y=smallplane._y-18-j*eval("bulletr"+j)._height;
eval("bulletl"+i)._x=L+templ;
eval("bulletr"+j)._x=R+tempr;
templ*=-1;
tempr*=-1;
i++;j++;
}
templ*=-1;
L=-7.5;
R=7.5;
}
_root.onEnterFrame=function(){//先初始后再做动画,按数字键0激发.
if(initialize){initializebullet_L();initializebullet_R();initialize=false;starts=true;}
if(initialize==false&&starts==true){
Motion();
//trace(templ);
}
if( Key.isDown(Key.LEFT))smallplane._x -= speed;
if( Key.isDown(Key.RIGHT))smallplane._x += speed;
if( Key.isDown(Key.UP))smallplane._y -= speed;
if( Key.isDown(Key.DOWN))smallplane._y += speed;
}
By The Way:
最近用C++在TC下做了个DOS环境的贪吃蛇,一共500多行代码,有兴趣的同志可以去这里看看,没兴趣就算了~~~
http://community.csdn.net/Expert/topic/3727/3727189.xml?temp=.918667
