搜索本站 搜索互联网 搜索
加入收藏
设为首页

Flash纯AS编写蝌蚪摆尾动画效果

正文字体: 2008-8-19 作者:yinggoing 来源:不详

  #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


人气
我要发言
我顶!
我踩!
将本文加入收藏夹
返回本栏目首页
返回首页
正文字体: 上一篇:
下一篇:
留言载入中...请稍后...
最多500个字符
  • 网友提交的评论和留言属网友个人意见,与本网站立场无关。
  • 请尊重网上道德,遵守中华人民共和国各项有关法律法规。
  • 以上资料除注明为本站原创以外,均为各方收集或网友推荐所得。以共享、研究为目的,不存在任何商业考虑。
  • 目前有些文章未注明作者或出处或标注错误,并非不尊重作者及出处网站,而是因为有些资料来源的不规范。如果有了解作者或出处的朋友,请告知,本网站将立即更正注明,并公开向作者或出处单位道歉。
  • 被摘录的对象如有异议,请与本站联系,联系方式见页尾,本站确认后将立即撤下。
  • 本站原创的内容如需转载需获得本站授权。
天气日历节庆
站内精确搜索
闽ICP备07074275号 CopyRight b2fm.com.cn 投稿信箱:gtxj45h1@yeah.net(请注明投稿) 研讨群:13601519
请使用1024*768或更大分辨率,IE6.0以上,FireFox2.0以上,Opera9.0以上,NetScape7.0以上,Safari3.0以上版本的浏览器浏览本站
每天5:00-8:00为服务器维护时间,在此期间网站可能无法访问,对您造成的不便,我们深感抱歉 [举报不良信息]
Valid XHTML 1.1 Transitional Valid CSS!
Powered By E-Dragon CMS 1.0 Beta