Flash AS教程:蝌蚪摆尾动画
所属分类:
媒体动画 / Flash教程
阅读数:
77
收藏 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 CLASS的基本编写规范
继续回来写教程。本来不想写这节的,因为这节的内容很多书上或者网上资料都有,而且写的比我要详细正规得多。但后来想想,还是写吧!为啥?凑篇幅呗~啊哈哈~而且后面几节要结合接宝的范例游戏,具体分析它的几个CLASS,所以,还是用一节把CLASS的写法说一下。可能我对CLASS
收藏 0赞 0分享
flash教程:使用拆分数字和文字的函数
flash的小函数:拆分数字和文字的函数.
以下为引用的内容:
/*
* 拆分数字和文字
*/
public function splitNS(s:String):Object{
var tNum:String=""
收藏 0赞 0分享
通过实例学习Flash AS3.0——案例六
相关文章: 通过实例学习Flash AS3.0——案例五
首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英文的,不利我们学习,我就充当一个translater,顺便可以让自己巩固一下
收藏 0赞 0分享
用Flash AS制作逼真的下雨动画效果
Flash教程:用Flash AS制作逼真的下雨动画效果
先看下效果:(附.swf文件)
制作过程
一、新建一图层,大小随意;
二、新建元件(影片剪辑):
1、制作雨滴并下落。使用直线工具(颜色设为灰色,1像素)画一短直线,使用选择工具将直
收藏 0赞 0分享
通过实例学习Flash AS3.0——案例五
相关文章: 通过实例学习Flash AS3.0——案例四
首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英文的,不利我们学习,我就充当一个translater,顺便可以让自己巩固一下
收藏 0赞 0分享
Flash CS3制作Fla形式的组件
本文为大家介绍如何制作Flash CS3中的[*.fla]形式的的组件(Component)。这种组件和SWC组件不同,它和CS3自带的组件一样能够双击进入组件里面编辑,是Flash CS3新增加的一种组件形态。下面我们制作一个MyButton组件为例子。
制作步骤:
收藏 0赞 0分享
通过实例学习Flash AS3.0——案例四
相关文章:通过实例学习AS3.0——案例三
首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英文的,不利我们学习,我就充当一个translater,顺便可以让自己巩固一下知识。
收藏 0赞 0分享
通过实例学习flash AS3.0——案例二
相关文章:通过实例学习AS3.0 --案例一
首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英文的,不利我们学习,我就充当一个translater,顺便可以让自己巩固一下知识。
水平有限,错误难免,欢
收藏 0赞 0分享
通过实例学习AS3.0——案例三
相关文章:通过实例学习flash AS3.0——案例二
首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英文的,不利我们学习,我就充当一个translater,顺便可以让自己巩固一下知
收藏 0赞 0分享
通过实例学习AS3.0
首先声明:本人大菜鸟一个,刚接触AS3不久,许多理念还没来得及灌输,这些case都是从网上down的,但因为解说是英文的,不利我们学习,我就充当一个translater,顺便可以让自己巩固一下知识。
水平有限,错误难免,欢迎大虾小虾,大鸟小鸟指正。
下面进入正题:
收藏 0赞 0分享
查看更多