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

所属分类: 媒体动画 / Flash教程 阅读数: 82
收藏 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 分享

AS3编程教学:Flash相册高级教程 实现相册的转场效果

本教程是在前一个进阶教程的基础上继续做优化和修改,既然是高级教材,势必会省去很多制作过程,主要精力放在编码工作上,希望同学们能认真学习
收藏 0 赞 0 分享

如何把Flash动画转换成GIF动画图片

Magic Swf2Gif不但可以快速高效地将SWF格式的Flash动画转换为GIF动画图片,而且在转换之后还能完整地保持原Flash动画中的动画帧数和分辨率。今天就教大家如何把Flash动画转换成GIF动画图片的方法,希望对大家有一定的帮助
收藏 0 赞 0 分享

Flash矢量插图教程:绘制绿色的小龙与花的插画场景

这是一篇Flash矢量插图教程,是教大家利用Flash矢量绘制小龙与花的插画场景,制作方法不是很难,效果也非常可爱漂亮。喜欢Flash矢量插图的朋友可以过来学习一下
收藏 0 赞 0 分享

如何运用Flash CS3循环背景的技巧

本例为Flash CS3仿真艺术设计系列教程,在本课中我们将学习如何在Flash中将单个背景元素在分隔的层中以不同的速度移动从而表现出循环动画的效果。
收藏 0 赞 0 分享

如何用Flash把相片图片做成电子相册

每次和朋友出去玩,都会拍摄很多照片。当和朋友分享这些照片时还要仔细挑选,然后打包分享给朋友。感觉挺麻烦的,后面想到把这些照片做成电子相册,要分享是把电子相册发出去就可以了。今天就教大家利用Flash把相片图片做成电子相册的方法
收藏 0 赞 0 分享

Flash制作火柴棍人光剑短打动画

本教程教大家利用Flash制作火柴棍人光剑短打动画的方法,双人光剑的短打,改进了不少制作方法,在光剑的处理上加入了滤镜,效果颇好我在这就谈谈我的制作经验光剑练习效果。希望对大家有一定的帮助
收藏 0 赞 0 分享

Flash实例教程:制作鼠标跟随的馋嘴兔兔

本例教朋友用Flash制作鼠标跟随效果。用鼠标拖动萝卜,兔兔眼睛总盯住萝卜,很可爱噢
收藏 0 赞 0 分享

Flash制作电影序幕的文字动画效果

这篇教程是教大家利用Flash的遮罩技术,来实现电影序幕的文字动画效果。制作方法非常简单,等大家和我一起做完了,就知道为什么能产生这样的效果了
收藏 0 赞 0 分享

Flash cs3鼠绘教程:图文讲解铰连身体部分

这篇为Flash CS3仿真艺术设计系列教程,今天我们来学习自由变形工具定位中心点位置产生相连的动作,希望通过本例的学习,大家可以有一定的收获
收藏 0 赞 0 分享
查看更多