前面講過制作粒子效果,這里我們為鼠標跟隨效果再增加一種形式,主要用到鼠標移動事件,動態生成對象,繪圖函數等知識,再次強調一下我們使用的Animate CC即原來的flash cc。
1、這里用的是AnimateCC,打開軟件,新建AS3文檔。
2、新建一個空影片剪輯。
3、設置這個影片剪輯的鏈接屬性為:Pflashs
4、進入空影片剪輯里,在時間軸加如下代碼:
var color:uint=0;var speed:Number=0;var i:Number=0;var rad:Number=0;var boxPar:Shape;function initView(_color:uint,_rad:Number):void{color=_color;speed=2;rad=_rad;AddParicle();this.addEventListener(Event.ENTER_FRAME,UpdateView);}function AddParicle():void{boxPar=new Shape();addChild(boxPar);boxPar.graphics.beginFill(color,1);boxPar.graphics.drawCircle(0,0,rad);boxPar.graphics.endFill();}function UpdateView(e:Event):void{boxPar.x+=2;boxPar.alpha-=0.05;if(boxPar.alpha<0.01){this.removeEventListener(Event.ENTER_FRAME,UpdateView);this["parent"].removeChild(this);}}
5、回到主場景,在主場景的時間軸加如下代碼:
var maxNum:int=3;var mcAry:Array=new Array();stage.addEventListener(MouseEvent.MOUSE_MOVE,MouseMoveEvent);function MouseMoveEvent(e:MouseEvent):void{for(var i=0;i<maxNum;i++){var color:uint=Math.random()*0xffffff;mcAry.push(new Pflashs());addChild(mcAry[mcAry.length-1]);mcAry[mcAry.length-1].initView(color,Math.random()*5);mcAry[mcAry.length-1].x=this.mouseX;mcAry[mcAry.length-1].y=this.mouseY;mcAry[mcAry.length-1].rotation=Math.random()*360;}}
6、運行后,移動鼠標,就能看到彩色粒子不斷產生,并飛向四處。
7、當然,這個效果也可以換成用花瓣或者樹葉進行制作,會有更好看的動態效果。
以上就是flash粒子拖尾效果的制作方法,希望大家喜歡,請繼續關注武林網。
相關推薦:
flash怎么制作文字透視效果?
flash cs6怎么制作牙刷刷牙的動畫效果?
flash怎么制作粒子慢慢增多并組合成文字的動畫?
新聞熱點
疑難解答