首先声名泡泡是别人做的(忘了是在帝国还是哪儿),只是看着直着上升不自然,就改了改。先看效果:
点击浏览该文件 代码:
H = 550;
W = 400;
r = random(360);
ballNum = 30;
i = 1;
while (i<ballNum) {
attachMovie("ball", "ball"+i, i);
this["ball"+i]._x = Math.random()*W;
this["ball"+i]._y = Math.random()*H;
this["ball"+i]._alpha = (Math.random()*70)+30;
this["ball"+i]._rotation = r+random(360);
v = 5;
vx = (Math.random()*10)-5;
rrr = Math.random()*2;
if (rrr>1) {
vy = Math.sqrt((v*v)-(vx*vx));
} else {
vy = -Math.sqrt((v*v)-(vx*vx));
}
this["ball"+i].vx = vx;
this["ball"+i].vy = vy;
i++;
}
_root.onEnterFrame = function() {
i = 1;
while (i<ballNum) {
this["ball"+i]._x = this["ball"+i]._x+this["ball"+i].vx;
this["ball"+i]._y = this["ball"+i]._y+this["ball"+i].vy;
if (this["ball"+i]._x>=W) {
this["ball"+i]._x = 0;
}
if (this["ball"+i]._x<=0) {
this["ball"+i]._x = W;
}
if (this["ball"+i]._y>=H) {
this["ball"+i]._y = 0;
}
if (this["ball"+i]._y<=0) {
this["ball"+i]._y = H;
}
if (i%2 == 0) {
//奇偶判定
this["ball"+i]._rotation += 5;
} else {
this["ball"+i]._rotation -= 5;
}
i++;
}
};
红字部分为自己所加。
原文件:
点击浏览该文件