製作過程
步驟如下:
1、啓動FLASH2004MX,然後導入一張背景圖片(提意:用晚上的夜色)
2、首先我們來製作一隻名稱爲熒火蟲的影片剪輯,選擇“ 插入”菜單中的“ 新建元件(CTRL+F8)”—名稱爲“熒火蟲”類型選擇影片剪輯。
3、然後選擇橢圓工具畫一個放射狀的小圓。(顏色由各人愛好而定)
4、將圖片拖到場景中,然後新建圖層2放入熒火蟲並命名爲(yhc_MC)。
5、選中熒火蟲影片剪輯,給它加入下面腳本
onClipEvent(load){
v = 3; //速度
_rotation = random(360); //讓熒火蟲旋轉爲任意一角度。
}
onClipEvent(enterFrame){
k = Math.pow(-1,random(2)); //隨機產生1和-1。
_rotation += k*random(11); //讓蟲旋轉爲-10到10之間。
a = _rotation*Math.PI/180; //將角度轉化爲弧度
dx = Math.cos(a)*v;
dy = Math.sin(a)*v;
//橫縱座標的移動量
_x += dx;
_y += dy;
//限定蟲移動的範圍
//先確定範圍。(寬:50--750;高:50--550)
if(_x = 750 && dx>0){
_rotation = Math.atan2(dy,-dx)*180/Math.PI;
} //超出限定範圍時,按照上面條件改變dx,
} //並用Math.atan2使旋轉角度發生相應變化,讓運動方向改變。
本文轉自:http://www.5uflash.com/flashjiaocheng/Flashdonghuajiaocheng/1113.html