您的位置: 首页 >> 文章首页 >> 设计教程 >> RSS订阅当前栏目
Flash教程:纯脚本语言编写蝌蚪摆尾
日期:2008-8-18 17:13:34 作者: 来源:本站收集

先看最终效果:

场景里代码

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 ()

MC里的代码

#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
热 点 文 章
热 点 文 章
Photoshop教程:图片合成 美女与红酒杯
photoshop教程:为MM皮肤美白
photoshop教程:精心使美女照片变身为海报效果
Photoshop教程:为丰满MM调色加瘦身
Photoshop教程:制作立体相框签名效果
photoshop教程:精心制作立体照片效果
photoshop教程:消除照片中的黑眼圈
Photoshop教程:简单去照片水印方法
Photoshop教程:调出浓烈色彩的美眉及通透皮肤
Photoshop教程:打造MM喜爱的卡通糖果娃娃
推 荐 文 章
Photoshop教程:精心打造飘扬的奥运会会族动画
Vegas打造《一个馒头引发的血案》
Excel教程:2007表格中可以使用的数字格式
Photoshop教程:精心制作塑料边框文字
Photoshop教程:制作怀旧及战火效果
Photoshop教程: 调色 一个人的精彩
Photoshop教程:非主流效果制作之效果
Photoshop教程:调出浓烈色彩的美眉及通透皮肤
Photoshop教程:另类抽丝法
Photoshop教程:手绘之抽线调法
photoshop教程:打造暖色调照片
photoshop教程:巧用PS通道抠复杂背景
首页 | 广告联系 | 下载排行榜 | 最近更新 | 联系我们 |
版权所有就去资讯站 by 中国 粤ICP备05000936号
Copyright(C) 1999-2006 Www.97info.Com All Rights Reserved
联系方式QQ:38766697 Email:xlxzcn@126.com