利用Tweener製作動畫 – 數大便是美

套用徐志摩的名言:「數大」便是美,意思是說數量多就是美,不過雖然數大便是美,但如果要針對多個元件製作動畫,那利用程式一定會比手工來的輕鬆,甚至可以更漂亮和壯觀,以下的範例就是利用Tweener針對較多的元件來製作動畫的結果,分享給大家參考!希望各位未來不會「數大」便是累。

Tweener 滿天星斗:利用Tweener針對星形製作Alpha動畫,是一個很簡單的範例。

import caurina.transitions.Tweener
import flash.display.MovieClip;

setInterval(starFn,50)
function starFn(){
	var scale:Number=Math.random()
	var mc:MovieClip=new star
	mc.x=Math.random()*500
	mc.y=Math.random()*500
	mc.scaleX=scale
	mc.scaleY=scale
	mc.alpha=0
	addChild(mc)
	Tweener.addTween(mc, {alpha:1, time:7, transition:"linear"});
	Tweener.addTween(mc, {alpha:0, time:3,delay:8, transition:"linear"});
}

滿天星斗 原始檔 下載


Tweener 擴散效果:利用Tweener針對球體來製作動畫,其中還應用到距離計算的Class,可以試著調整參數(彈出距離變數、彈出數量…等)來觀察改變的情況。

import flash.display.Sprite;
import roMc;
import flash.geom.Point;
import caurina.transitions.Tweener;

//變數定義區塊
var centerPoint:Point = new Point  ;//圓形中心點
var i:int = 1;//迴圈變數
var radius:int = 50;//彈出距離變數
var no:int = 20;//彈出數量
var circleArray:Array=new Array//球體陣列(針對移除使用)
var sec:int=1//動畫秒數
var hold:Number=0.1//延遲秒數

centerPoint.x = stage.stageWidth / 2;
centerPoint.y = stage.stageHeight / 2;

stage.addEventListener(MouseEvent.CLICK,clickFn);

function clickFn(e:MouseEvent)
{
	while (circleArray.length > 0) {
			removeChild(circleArray.pop());
	}
	Tweener.removeAllTweens();
	showFn();
}

function showFn()
{
	for (i=1; i<=no; i++)
	{
		var mc:Sprite = new ball  ;
		circleArray.push(mc)
		var angle:Number = 2 * Math.PI / no * i;
		var targetPoint:Point = new Point();
		targetPoint.x = radius * Math.cos(angle) + centerPoint.x;
		targetPoint.y = radius * Math.sin(angle) + centerPoint.y;
		addChild(mc);
		mc.x = centerPoint.x;
		mc.y = centerPoint.y;
		mc.alpha = 0;
		Tweener.addTween(mc, {alpha:1,x:targetPoint.x,y:targetPoint.y, time:sec, transition:"linear",delay:i*hold});
		Tweener.addTween(mc, {alpha:0,x:centerPoint.x,y:centerPoint.y, time:sec, transition:"linear",delay:i*hold+(no*hold+1)});
	}
}

擴散效果 原始檔 下載

You may also like...

26,043 Responses

  1. SamuelBix表示:

    purchase cipro: CiPharmDelivery – cipro pharmacy

  2. KennethPah表示:

    ciprofloxacin generic buy cipro without rx where to buy cipro online

  3. RobertKen表示:

    Рекомендую https://telegra.ph/Kak-ya-ne-popalsya-na-moshennikov-i-vybral-opytnogo-hakera-12-15-2 . Проверенные хакеры, которые предоставляют профессиональные услуги.

  4. SamuelBix表示:

    ciprofloxacin 500 mg tablet price: ci pharm delivery – buy cipro cheap

  5. KennethPah表示:

    order amoxicillin no prescription Amox Star amoxicillin 500mg price canada

  6. RobertJar表示:

    buy cipro without rx: CiPharmDelivery – buy generic ciprofloxacin

  7. KennethPah表示:

    cheap clomid without insurance where can i get cheap clomid get generic clomid without rx

  8. RobertKen表示:

    Рекомендую https://telegra.ph/Kogda-i-kak-ya-obratilsya-k-nastoyashchim-vzlomshchikam-12-15-2 . Проверенные хакеры, которые предоставляют профессиональные услуги.

  9. DanielAbice表示:

    https://clomidonpharm.com/# generic clomid without prescription

  10. RobertKen表示:

    Рекомендую Взломать пк через интернет . Проверенные хакеры, которые предоставляют профессиональные услуги.

  11. En sevdiğim slot oyunu The Dog House, her zaman büyük kazançlar elde ediyorum.

  12. SamuelBix表示:

    buy amoxicillin online mexico: how to get amoxicillin over the counter – can i buy amoxicillin over the counter in australia

  13. DanielAbice表示:

    https://cipharmdelivery.com/# cipro pharmacy

  14. DanielAbice表示:

    https://cipharmdelivery.com/# buy cipro online usa

  15. продамус промокод скидка http://rubiz.forum.cool/viewtopic.php?id=3874#p139 .

  16. SamuelBix表示:

    how can i get clomid no prescription: get clomid tablets – where to get generic clomid without dr prescription

  17. RobertJar表示:

    can i order prednisone: Predni Best – prednisone 60 mg daily

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。