风雨中的树——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;
}
}
}
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器