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

所属分类: 媒体动画 / Flash教程 阅读数: 64
收藏 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制作可爱的简单线条笑脸方法,教程制作出来的笑脸非常可爱,而且方法不是很难,推荐过来,大家一起来学习吧
收藏 0 赞 0 分享

flash中制作文字按照顺序显示出来的gif动画

这篇教程是向脚本之家的朋友介绍flash中制作文字按照顺序显示出来的gif动画方法,教程制作出来的动画效果非常漂亮,难度不是很大,推荐过来,大家快快来学习吧
收藏 0 赞 0 分享

flash制作一个一个字的冒出来的打字效果

这篇教程是向脚本之家的朋友介绍flash制作一个一个字的冒出来的打字效果方法,教程很简单的,很适合新手来学习,推荐到脚本之家,喜欢的朋友快快来学习吧
收藏 0 赞 0 分享

用flash制作画卷展开、合拢的gif动画效果

这篇教程是向脚本之家介绍用flash制作画卷展开、合拢的效果方法,教程制作出来的效果很不错,难度不是很大,推荐到脚本之家,喜欢的朋友快快来学习吧
收藏 0 赞 0 分享

flash怎么制作太阳月亮地球演示动态图?

flash怎么制作太阳月亮地球演示动态图?这个动图的制作过程很麻烦,因为出现的元素很多,下面我们就来看看绘制的图文教程,每一步都有,参数很清楚,想学习的朋友可以进来参考一下
收藏 0 赞 0 分享

flash制作一闪一闪的gif动画文字按钮效果

这篇教程是向脚本之家的朋友介绍flash制作一闪一闪的gif动画文字按钮效果方法,教程真的很不错,制作出来的效果很漂亮,推荐过来,一起来学习吧
收藏 0 赞 0 分享

在flash中制作由花生组成的好看花型

这篇教程是向脚本之家的朋友介绍在flash中制作由花生组成的好看花型方法,教程制作出来的图形很漂亮,难度也不是很大,推荐到脚本之家,喜欢的朋友一起来学习吧
收藏 0 赞 0 分享

flash逐帧动画制作全过程解析

这篇教程是向脚本之家的朋友分享flash逐帧动画制作全过程,教程非常基础,很适合新手来学习,推荐过来,有兴趣的朋友可以过来学习
收藏 0 赞 0 分享

flash引导层动画:引导层制作飞行的飞机

这篇教程是向脚本之家的朋友分享flash引导层动画:引导层制作飞行的飞机教程,教程真的很不错,很适合新手来学习,推荐到脚本之家,喜欢的朋友快快来学习吧
收藏 0 赞 0 分享

Flash把静态的水的图片制作成形象逼真的水波效果

这篇教程是向脚本之家的朋友分享Flash把静态的水的图片制作成形象逼真的水波效果方法,教程真的很不错,很值得大家学习,推荐到脚本之家,喜欢的朋友快快来学习吧
收藏 0 赞 0 分享
查看更多