流星划过天空效果

| |
[不指定 2006/04/03 09:05 | by admin ]
做一流星,然后定义为影片剪辑,属性内实例名定义为fallingstar.上面加:
onClipEvent(load){
var angle=60;//流星的角度
var radian=angle*Math.PI/180;//转换为弧度
this._rotation=angle;//设置流星的角度
this._x=Math.random()*Stage.width;
this._y=0;//流星运动的起点坐标,x随机,y为0,让流星位于主场景之上
time=100;//运动时间控制
v=random(6)+2;//速度为一个随机值
a =0.09;//y方向的加速度,可以使效果更加逼真
vx=Math.cos(radian)*v;
vy=Math.sin(radian)*v;//x,y方向的速度
}
onClipEvent(enterFrame){
vy+=a;//y方向的速度加上加速度,这样水平方向是匀速运动,垂直方向是加速运动
_x+=vx;
_y+=vy;//设置流星的坐标
_alpha=_xscale=_yscale=time;//流星的缩放比例,用时间来控制
time-=2;//时间不断递减
if(_x<0||_x>Stage.width||_y<0||_y>Stage.height){
this.removeMovieClip();//如果流星超出范围删除
}
}

主场景上加入:

var n=0;
onEnterFrame=function(){
fallingstar.duplicateMovieClip("fallingstar"+n++,n);
}

作者:Else 's Blog
地址:http://www.aixq.com/post/7/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
  • 中查看更多“流星划过天空效果”相关内容
  • 中查看更多“流星划过天空效果”相关内容
  • 中查看更多“流星划过天空效果”相关内容
  • 中查看更多“流星划过天空效果”相关内容
  • 中查看更多“流星划过天空效果”相关内容
  • 中查看更多“流星划过天空效果”相关内容
  • 代码 程序 编程 | 评论(0) | 引用(0) | 阅读(3389)
    发表评论
    表情
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    打开HTML
    打开UBB
    打开表情
    隐藏
    昵称   密码   游客无需密码
    网址   电邮   [注册]