大家好,我是阿刚。好久没写教程了,最近个人的事情比较多,前些天做一个水波效果,研究了这个action,还算比较有特点,拿出来大家分享一下了。(语句自己增改的地方很多,哈我的action也不是很强)假如有写的多余的地方请高手多修改了。废话不说了,先看效果吧... (注:假如转贴请注明 作者:阿刚 谢谢!)
鼠标移到对象中心位置,看看效果:
1:先在场景绘制一个任意形,图像也可以。f8转换为影片剪辑。
2:紧接着,按f8再转换一次影片剪辑“元件2”(也可以ctrl+F8拖进去,这里是个人习惯。)
3:双击进入“元件2”,给影片剪辑起名称为“aqua0”。
4:新建图层2,层2第一帧点右键,给动作:
5:给第二层依次按f7插入三个空白要害帧。他们的action依次是:
第一帧:
d = 0;
i = 0;
numAqua = 0;
minAlpha = 70;
threshold = 500;
clp = aqua0;
maxChange = 1.57;
maxChange2 = 1.04666666666667;
halfMax = maxChange/2;
halfMax2 = maxChange2/2;
maxSpeed2 = 2;
trajectory = new Array(15);
trajectory[0] = 0;
第二帧:
i = numAqua;
while (i>=0) {
baseClip = eval("aqua"+i);
dx = baseClip._x-_xmouse;
dy = baseClip._y-_ymouse;
d = Number(Math.sqrt((dx*dx)+(dy*dy)));
if (threshold<d) {
d = threshold;
}
closeness = (Math.pow(((threshold-d)/threshold)*10, 1.8)*0.016)*100;
if (!closeness) {
closeness = 0;
}
if (0<closeness) {
if (97<closeness) {
if (baseClip._xscale<20) {
removeMovieClip(baseClip);
}
if (numAqua<15) {
numAqua = numAqua+1;
duplicateMovieClip("aqua"+i, "aqua"+numAqua, numAqua);
newClip = eval("aqua"+numAqua);
trajectory[numAqua] = 0;
colors[numAqua] = new Color(newClip);
currentColor[numAqua] = new Object();
colors[numAqua].setTransform(currentColor[numAqua]);
newClip._x = newClip._x+(random(5)+5);
newClip._y = newClip._y+(random(5)+5);
baseClip._xscale = baseClip._xscale-20;
baseClip._yscale = baseClip._yscale-20;
newClip._xscale = baseClip._xscale;
newClip._yscale = baseClip._yscale;
}
}
currentColor.ra = startR-((closeness*0.01)*(startR-endR));
currentColor.ga = startG-((closeness*0.01)*(startG-endG));
currentColor.ba = startB-((closeness*0.01)*(startB-endB));
colors.setTransform(currentColor);
a = (closeness*(100-minAlpha))*0.01;
baseClip._alpha = a+minAlpha;
speed = closeness/8;
angle = (Math.random()*100)%maxChange;
trajectory = (trajectory-halfMax)+angle;
} else {
currentColor.ra = startR-((closeness*0.01)*(startR-endR));
currentColor.ga = startG-((closeness*0.01)*(startG-endG));
currentColor.ba = startB-((closeness*0.01)*(startB-endB));
colors.setTransform(currentColor);
a = (closeness*(100-minAlpha))*0.01;
baseClip._alpha = a+minAlpha;
speed = maxSpeed2;
angle = (Math.random()*100)%maxChange2;
trajectory = (trajectory-halfMax2)+angle;
}
vx = speed*Math.cos(trajectory);
vy = speed*Math.sin(trajectory);
baseClip._x = baseClip._x+vx;
baseClip._y = baseClip._y+vy;
i = i-1;
}
第三帧:
gotoAndPlay(2);
6:基本上大功告成。最后,回到场景,新建一个层,加个背景图就ok了,别忘了把背景图放到最下层哦。你也可以多复制一些调整大小,这个大家自己发挥了。
源文件下载: fs.rar
进入论坛和作者一起讨论学习:http://space.flash8.net/bbs/thread-342549-1-1.html