Flash AS实现的蝌蚪摆尾动画的教程 程序员文章站 2023-12-12 22:14:34 本例介绍使用Flash的AS编写蝌蚪摆尾动画效果,希望朋友们喜欢~~ 场景里代码 [code] Object.environment = this; Math.prototype.degrees = function (r) ... 08-09-10... 本例介绍使用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 AS实现的蝌蚪摆尾动画的教程 html5 css3实例教程 一款html5和css3实现的小机器人走路动画 FLASH怎么制作一个小蝌蚪*游泳的动画? Flash AS3制作火苗跳动的gif动画教程 html5 css3实例教程 一款html5和css3实现的小机器人走路动画 flash图层混合模式制作图片切换特效动画的教程 Flash AS教程:蝌蚪摆尾动画 Flash组件教程:组件动画效果的修改 Flash CS4来制作漂亮的气泡动画教程 flash怎么制作翻滚的文字动画? flash动态文字制作教程