Flash AS实现的蝌蚪摆尾动画的教程

所属分类: 媒体动画 / Flash教程 阅读数: 104
收藏 0 赞 0 分享
本例介绍使用Flash的AS编写蝌蚪摆尾动画效果,希望朋友们喜欢~~
 

 
场景里代码

复制代码
代码如下:

  Object.environment = this;
  Math.prototype.degrees = function (r)
  {
  return (r * 180 / 3.141593E+000);
  };
  maxtents = 3;
  this.onEnterFrame = function ()
  {
  if (!random(30) && tents < maxtents)
  {
  var nombre = "tent" + String(depth++);
  var neo = this.attachMovie("tentacle", nombre, depth);
  neo._x = random(600);
  neo._y = 370;
  neo.theta = 270;
  ++tents;
  } // end if
  };
  stop ()

#initclip 1

复制代码
代码如下:

  function TentacleClass()
  {
  this.numNodes = 27;
  this.head = 2 + random(4);
  this.girth = 8 + random(12);
  this.speedCoefficient = 9.000000E-002 + random(10) / 50;
  this.friction = 9.000000E-001 + random(10) / 100;
  this.muscleRange = 20 + random(50);
  this.muscleFreq = 1.000000E-001 + random(100) / 250;
  this.generateNodes();
  this.onEnterFrame = this.move;
  } // End of the function
  TentacleClass.prototype = new MovieClip();
  TentacleClass.prototype.generateNodes = function ()
  {
  this.node = new Array();
  var n = 0;
  while (n < this.numNodes)
  {
 
  var point = {x: 0, y: 0};
  this.node.push(point);
  ++n;
  } // end while
  };
  TentacleClass.prototype.move = function ()
  {
  this.tv = this.tv + 5.000000E-001 * (Math.random() - Math.random());
  this.theta = this.theta + this.tv;
  this.tv = this.tv * this.friction;
  this.node[0].x = this.head * Math.cos(1.745329E-002 * this.theta);
  this.node[0].y = this.head * Math.sin(1.745329E-002 * this.theta);
  this.count = this.count + this.muscleFreq;
  this.thetaMuscle = this.muscleRange * Math.sin(this.count);
  this.node[1].x = -this.head * Math.cos(1.745329E-002 * (this.theta + this.thetaMuscle));
  this.node[1].y = -this.head * Math.sin(1.745329E-002 * (this.theta + this.thetaMuscle));
  var i = 2;
  while (i < this.numNodes)
  {
  var dx = this.node.x - this.node[i - 2].x;
  var dy = this.node.y - this.node[i - 2].y;
  var d = Math.sqrt(dx * dx + dy * dy);
  this.node.x = this.node[i - 1].x + dx * this.girth / d;
  this.node.y = this.node[i - 1].y + dy * this.girth / d;
  if (i == 2)
  {
  this._x = this._x - dx * this.speedCoefficient;
  this._y = this._y - dy * this.speedCoefficient;
  if (this._x + this._width < 0    this._x - this._width > 600    this._y + this._height < 0    this._y - this._height > 400)
  {
  --Object.environment.tents;
  this.removeMovieClip();
  } // end if
  } // end if
  ++i;
  } // end while
  this.clear();
  this.moveTo(this.node[1].x, this.node[1].y);
  var i = 2;
  while (i < this.numNodes)
  {
  this.lineStyle(int(this.numNodes - i) * (this.numNodes - i) / 20, 16777215, 100);
  this.lineTo(this.node.x, this.node.y);
  ++i;
  } // end while
  };
  Object.registerClass("tentacle", TentacleClass);
  #endinitclip
更多精彩内容其他人还在看

flash怎么绘制一个按笔画写出来的春字动画?

flash怎么绘制一个按笔画写出来的春字动画?flash中想要制作一个写出来的文字动画小狗哦,该怎么制作呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么定位图元? flash图元的三种定位方法

flash怎么定位图元?flash中很多朋友为了定位图元而烦恼,位置的对齐涉及到两个概念,注册点和变形点,下面我们就来看看flash图元的三种定位方法,需要的朋友可以参考下
收藏 0 赞 0 分享

FLASH怎么给透明按钮添加播放代码?

FLASH怎么给透明按钮添加播放代码?FLASH中国想要给按钮赋予一些功能,比如播放功能,该怎么办呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

Flash怎么制作滚动的方块GIF动画?

Flash怎么制作滚动的方块GIF动画?Flash中想要制作一个动画,今天我们就来看看比较简单的实例动画,就是一个滚动的方块,该怎么制作呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么给图片制作伸缩动画效果?

flash怎么给图片制作伸缩动画效果?flash中想要给图片添加一些动态显示效果,该怎么制作伸缩的动画效果呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

flash文件中的图片怎么替换?

flash文件中的图片怎么替换?flash文件中想要替换某一张图片,该怎么替换呢?下面我们就来看看详细的教程,很简单,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么使用绘图工具?

flash怎么使用绘图工具?flash中想要绘制图形,需要使用绘图工具,今天我们就来看看flash中绘图工具的使用方法,很简单,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么画月牙和云朵图形?

flash怎么画月牙和云朵图形?flash中想要画一个月亮和云朵组成的图,该怎么绘制呢?下面我们就来看看详细的画法,很简单,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么给图片添加聚光灯照射效果?

flash怎么给图片添加聚光灯照射效果?flash中想要给图片添加聚光灯效果,这样方便聚焦一个人物,该怎么实现呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

flash怎么制作一段写字动画?

flash怎么制作一段写字动画?flash中想要制作一段毛笔写字的动画,该怎么制作呢?下面我们就来看看详细的教程,很简单,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多