利用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...

28,106 Responses

  1. Charlesbot表示:

    http://maxpillsformen.com/# cheapest cialis

  2. Donaldabula表示:

    cheapest viagra buy viagra online sildenafil online

  3. Barrybib表示:

    ed rx online: fast pills easy – buy ed pills online

  4. Diplomi_jupi表示:

    купить диплом о мед образовании купить диплом о мед образовании .

  5. Diplomi_ahpi表示:

    купить диплом механика в старом осколе 4russkiy365-diplomy.ru .

  6. Barrybib表示:

    Cialis 20mg price in USA: buy cialis online – Cialis 20mg price in USA

  7. Donaldabula表示:

    Viagra tablet online cheap viagra Viagra online price

  8. сравнение процессоров для пк https://topcpu.ru/ .

  9. Donaldabula表示:

    buy erectile dysfunction treatment FastPillsEasy where to buy erectile dysfunction pills

  10. какой процессор лучше https://topcpu.ru .

  11. Diplomi_eqpi表示:

    купить диплом вуза в нижнем тагиле купить диплом вуза в нижнем тагиле .

  12. Barrybib表示:

    order ed pills: fast pills easy – online ed medications

  13. рейтинг процессоров для игр https://www.topcpu.ru .

  14. BrettTIT表示:

    Buy generic 100mg Viagra online: Viagra online price – Cheap generic Viagra online

  15. BrettTIT表示:

    Cheap Cialis: Max Pills For Men – Cialis over the counter

  16. рейтинг игровых процессоров https://topcpu.ru/ .

  17. BrettTIT表示:

    п»їcialis generic: buy cialis online – Generic Cialis without a doctor prescription

  18. Charlesbot表示:

    https://maxpillsformen.com/# Cheap Cialis

  19. Barrybib表示:

    Buy Tadalafil 20mg: Buy Tadalafil 10mg – Generic Tadalafil 20mg price

  20. BrettTIT表示:

    cheap ed medication: fast pills easy – best ed pills online

  21. Charlesbot表示:

    https://fastpillsformen.com/# Viagra online price

  22. Charlesbot表示:

    http://maxpillsformen.com/# Cialis over the counter

  23. Donaldabula表示:

    Buy Viagra online cheap Fast Pills For Men Viagra tablet online

  24. qhqmobdxn表示:

    Whether you’re a competitive poker player looking to take the tables to-go or a casual better wanting to pass time and possibly win big, these three Zynga Poker alternatives offer mobile poker games with the chance to cash out and win real money prizes. Bovada Poker, having the US market as its main target, is a leading card room with a wide range of trusted games. The card room was open from 2004 to 2016, then reopened in 2017 with a new user-friendly interface, a fantastic variety of tournaments, and regular poker games to enjoy. Without a doubt, Bovada Poker is one of the leading pokers in the United States and is among the top ten poker websites worldwide. Founded in January of 2007, Zynga Poker offers an easy and accessible way to enjoy poker games on the go. Designed to encourage international connections between poker lovers, Zynga Poker allows players to enjoy low-risk gameplay by using in-app currency only. So essentially you cannot win real money on Zynga Poker at this time.
    https://www.poetrynook.com/user/papartypoker
    There are many advantages to playing slots online. Slots are random and unpredictable and require almost no skill while offering enticing jackpot prizes. But how these games work remains a mystery to many players. With little behind-the-scenes knowledge, new players wonder if a casino can secretly control slots and cheat them out of their winnings. This blog is your trusted source to learn how to play and win at real money casino sites. Find useful advice and tips from the expert players online gambling industry. In addition to lower payouts, it’s logical to think that if a casino wants to make more money, it should add more machines. But the opposite has proven to be true. The counterintuitive logic is all about odds. “The less amount of slot machines a casino has on a floor, the higher the net-win percentage goes up,” explains Nick Antenucci, a lawyer and lobbyist at Davidoff Hutcher & Citron who has worked in New York’s gaming industry for years. “It’s more about math than it has to do with gaming. Less machines, less odds for the players.”

發佈留言

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