一杯热咖啡

      Flash课件设计 2007-8-8 9:0

在做了一个烟雾效果之后,拿出这张旧图,给它加热了一下。欢迎到这里来的朋友都来品一下这杯咖啡的味道

核心代码如下:

t1 = 0;//记录层深度
cup_mc.swapDepths(1); //用咖啡杯的图片遮住烟雾的起点
onEnterFrame = function () {
 var mc = b_mc.duplicateMovieClip("mc" + t1, -t1);
 //复制烟雾的粒子
 mc.t = 0;
 mc.dx = (Math.random()*6 - 3) / 8  ;
 mc.dy = 1;
 
 mc.onEnterFrame = function(){
  //让烟雾粒子进行自主的运动
  this.dt = 1 + this.t / 10;
  //y轴方向进行加速移动
  this._y = -this.dy * this.dt * this.dt + b_mc._y ;
  //x轴方向随机的发生一些偏移
  this._x = this.dx * this.t + b_mc._x  ;  
  this.t++;
  
  this._alpha -= 0.8;
  if( this._alpha < 0){
   //当元件在屏幕上消失后,就删除掉
   this.removeMovieClip(this);
  }
 }
 
 if(t1++> 100){
  //超过100个元件以后,层深度的使用又从零开始
  t1 = 0;
 }
};

标签集:TAGS:粒子运动 烟雾效果
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}