风雨中的树—AS效果的实际应用 |
| 作者:佚名 来源:不详 更新:2007-1-13 20:48:13 错误报告 我要投稿 |
风雨中的树——AS效果的实际应用 数学公式是自然美的原型?:) 这个程序是以前做的,很不完善。分下面几块 1.造雨: amount = _parent.strong*2; j = amount/40; //雨量控制 drop._visible = false; do { duplicateMovieClip("drop", "d"+i, i); setProperty("d"+i, _x, random(800)-100); setProperty("d"+i, _y, random(50)); setProperty("d"+i, _xscale, 30+random(70)); setProperty("d"+i, _yscale, 70+random(40)); setProperty("d"+i, _alpha, random(50)+35); i1 = i-200; removeMovieClip("d"+i1); i = i+1; j = j-1; } while (j>=0); //制造随机的雨
2.造风 onClipEvent (load) { t0 = getTimer(); tt0 = getTimer(); tinterval = 10000; interval = 1000; wind = new Sound("windsound"); rain = new Sound("rainsound"); } onClipEvent (enterFrame) { t1 = getTimer(); t = t1-t0; tt = t1-tt0; if (tt>=tinterval) { tt0 = getTimer(); } if (t>=interval) { strong = 20+random(9)*10; rain.setVolume(strong); direction = random(2); if (direction == 1) { pan = strong; } else { if (direction == 0) { pan = -strong; } } wind.setPan(pan); volume = 0; wind.setVolume(volume); windsound.gotoAndPlay("start"); t0 = getTimer(); tt0 = getTimer(); interval = strong*100; } now = Math.sin(((1-(t/interval)*2)*Math.PI)/2); //from 1~-1 if (direction == 1) { pan = strong*now; } else { if (direction == 0) { pan = -strong*now; } } wind.setPan(pan); if (t>=interval/2) { volume = strong*(now+1); } else { if (t<=100) { volume = 0; } else { if (t<=interval/2) { volume = strong*(1-now); } } } if (volume<0) { volume = 0; windsound.gotoAndStop("stop"); } wind.setVolume(volume); if (direction == 1) { setProperty("rain.drop", _rotation, -volume/3); } else { if (direction == 0) { setProperty("rain.drop", _rotation, volume/3); } } }
3.树的摇摆 onClipEvent (enterFrame) { nowt = (Math.sin(((1-(tt/tinterval)*2)*Math.PI*Math.exp(t/interval))*2)*Math.exp((-t/interval)*5); //周期衰变大阻尼震荡 direction = _parent.direction; if (direction == 1) { _rotation = -nowt*40; } else { if (direction == 0) { _rotation = nowt*40; } } }
|
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |