利用GreenSock Tweening Platform製作動畫

因為馬老師剛開始利用程式製作補間動畫的Class是Tweener,所以前面介紹了很多篇這方面的文章,但當然這方面的Class不是只有Tweener而已,所以接下來介紹一個目前發展起來比Tweener還要棒很多的Class,它是由GreenSock研發的Tweening Platform(補間平台),其中包含了:「TweenNano」、「TweenLite」、「TweenMax」、「TimelineLite」、「TimelineMax」。

為什麼說他發展得比較好呢?除了Tweener能做到的幾乎它都可以以外,也因為Tweener已經停止開發,所以未來將不會有新增的功能,但TweenMax還在不斷的更新中,在官網還有以下的比較案例:

各種補間動畫 速度測試

從上面的案例可以看出來利用GreenSock所研發的Tweening Platform的執行效能會比其他的好(FPS越高越好),所以接下來就來看看GreenSock Tweening Platform的簡介。

TweenNano、TweenLite與TweenMax算是同樣功能,但在製作後檔案容量是TweenNano<TweenLite<TweenMax,也就是說利用TweenNano所製作出來的動畫容量是最小的,舉個例來說,像這樣的動畫效果,TweenNano製作後swf大小為:5KB、TweenLite:8KB、TweenMax:21KB,不過在功能上面也是TweenNano<TweenLite<TweenMax,也就是說TweenMax可以掌控的效果比較多,也更具有彈性,例如:TweenNano就沒有辦法執行:pause()、play()、restart()…等,而TweenLite沒辦法執行:貝茲曲線運動、濾鏡…等,所以要用哪個版本的Tween,端看想要製作的動畫效果來考量,官方也有針對此三者製作比較表供大家參考。

另外TimelineLite和TimelineMax算是同樣功能,但看到後面的英文單字應該可以了解與上述具有相同的關聯,而這方面的Class是可以掌握時間軸上面的變化,在Tweener中,我們只能用Delay來控制動畫先後順序,而在GreenSock所研發的Tweening Platform中則可以利用TimlinelineLite或TimelineMax來處理。

馬上來介紹有關這個Class的一些使用方式,與Tweener一樣的是必須先下載備用載點),然後在需要使用的Flash檔案中import該Class,下載解壓後會有以下的資料夾:

  • badges:GreenSock圖標。
  • com:主要Class資料夾。
  • demo_swfs:裡面有很多swf的展示,對於想要了解本Class非常有幫助。
  • docs:參考文件。

在import時,看你想要使用的Class來import,例如需要使用TweenNano則:

import com.greensock.TweenNano;

若需同時使用TweenLite和TweenMax則:

import com.greensock.TweenLite;
import com.greensock.TweenMax;

想偷懶,則:(別擔心,Flash只會內嵌有使用到的部分)

import com.greensock.*;

至於製作補間的程式碼,其實官方就有製作swf來給大家參考,這邊也把官方的範例放進來給大家參考:

基礎動畫製作 範例檔

上面的案例可以讓你測試動畫效果,下方也會產生該段動畫的程式碼供你使用,實在是非常方便。另外關於Tween的語法也可以改成下面這種版本:

TweenLite.from(mc, 1.5, {y:0, alpha:0});

一個是告訴動畫要去哪,另一個是告訴動畫要從哪開始變化,關於Tweener可以使用的delay、onComplete、onStart、onUpdate…等,這個Class也都可以使用,例如:

TweenLite.to(mc, 1.5, {x:100, ease:Elastic.easeOut, delay:1, onComplete:okFn});
function okFn() {
    trace("動畫執行完畢");
}

這個Class還有很多特別的動畫效果,例如:濾鏡、短距離旋轉、貝茲曲線、聲音、色彩變換…等,大家也可以參考官方製作的swf來參考動畫效果與取得程式碼:

特殊動畫效果 範例圖

在動畫控制上面可以使用如下的程式碼來控制動畫:

var myTween:TweenLite = new TweenLite(mc, 1, {x:100, y:100});

myTween.pause();
//暫停動畫播放

myTween.resume();
//恢復動畫播放

myTween.reverse();
//反向播放

myTween.play();
//播放動畫

myTween.restart();
//重播動畫

myTween.invalidate();
//移除補間並使元件恢復原始狀態

myTween.kill();
//清除補間動畫

TweenLite.killTweensOf(mc);
//清除所有物件之補間動畫

以上是有關GreenSock Tweening的介紹,接下來介紹有關TimelineLite與TimelingMax的部分。

就像上面有提到在Tweener中我們如果希望三個元件在不同的時間點開始移動,就只能使用delay或是另外寫程式來控制,現在我們可以使用Timeline相關的Class來完成這樣的任務,甚至還可以讓時間軸倒著播放也沒問題,以下就是有關TimelineLite的官方範例:

TimelineLite 範例檔

另外是TimelineMax的範例檔,供大家參考:

TimelineMax 範例檔

以上就是針對GreenSock Tweening Platform大致的介紹,建議有空可以前往官網鑽研更多其他的功能,另外其實GreenSock另外還有TransformManagerLoaderMax,各位也可以先參考官網文章或是未來再跟大家分享我的使用心得。

註:本範例所使用的範例版權屬於GreenSock公司所有。

You may also like...

30,277 Responses

  1. Lazrjlw表示:

    Где приобрести диплом по актуальной специальности?
    Заказать диплом университета по доступной цене можно, обращаясь к проверенной специализированной фирме.: kazdiplomas.com

  2. GarrettMom表示:

    canlД± casino oyna en gГјvenilir online casino casino siteleri 2025 casinositeleri1st.shop

  3. WilliamDeeli表示:

    Мы готовы предложить дипломы психологов, юристов, экономистов и других профессий по невысоким тарифам. Дипломы производятся на настоящих бланках Заказать диплом о высшем образовании diplomt-tver69.ru

  4. Kennethedugs表示:

    Of course, he said yes to coming back to the series, which eventually required him to live in Italy for a few months for filming.
    hop exchange
    During production, White revealed to Gries that Greg is “very sinister.” That became rather irrefutable by the season’s climax, which saw Tanya’s demise orchestrated by her now-husband.

    Come Season 3, Gries had to rewrite Greg’s backstory again, this time drawing from some unlikely sources for inspiration, like HBO docuseries “The Jinx,” about late convicted killer Robert Durst, and the case involving the man who came to be known as the Tinder Swindler.

    Gries said he was struck by Durst’s “kind of seemingly even keel personality,” which served as a model for where Greg was headed, someone “who doesn’t really show a great deal of emotion, doesn’t seem to get too angry, just gets a little bit irritated and is dangerous.”

    “There’s a bridled rage underneath. And those kind of people I find – at least with respect to Gary, Greg, Gary – fascinating,” he said.

    And yet, while searching for an empathetic way back to portraying his character, Gries kept wondering if there was anything still redeeming about Greg.
    An important “wake up moment” came during a decisive conversation he had with White just before filming in Thailand, in which the show’s creator said of Greg, in no uncertain terms: “He’s a psychopath.”

    “And that was it. It was like, ‘back to the drawing board.’ And it really did help me,” Gries said.

    The penultimate episode of the series will air on Sunday, an evening that thanks to “Lotus” and other shows has again become a night of appointment viewing amid a general move away from binge watching. Gries said he appreciates the shift.

    “We’re a society that in a weird way doesn’t understand the beauty of waiting. The beauty of the space between the notes,” he shared. “If I binged (‘White Lotus’) I’d feel like I just ate too many chocolates. It just wouldn’t be the same. You need to process this.”

    “The White Lotus” airs Sundays at 9 p.m. EDT on HBO, with the episode available to stream on Max. HBO and Max, like CNN, are owned by the same parent company, Warner Bros. Discovery.

  5. RobertCex表示:

    sweet bonanza siteleri: sweet bonanza giris – sweet bonanza 1st sweetbonanza1st.shop

  6. BradyGem表示:

    slot casino siteleri: deneme bonusu veren siteler – casino siteleri 2025 casinositeleri1st.com

  7. RobertCex表示:

    bahis oyun siteleri: casibom resmi – casino siteleri 2024 casibom1st.com

  8. Danielbor表示:

    ‘White Lotus’ villain Jon Gries reveals the true crimes that inspired his twisty take on Greg/Gary
    fixedfloat exchange
    When Season 3 of “The White Lotus” premiered last month, the shock was palpable when returning character Belinda recognized a familiar face at the resort in Thailand: Greg Hunt, the wily suitor of the late Tanya McQuoid.

    As the season has unfolded, Greg (played by Jon Gries) has emerged as an antagonist, particularly after Belinda dove into the investigation surrounding Tanya’s death and learned that Greg, who now goes by Gary, evaded questioning by authorities.

    On a show famous for reinventing itself, the same has been asked of the actor, who says that playing the ever-shifting character has been a welcome challenge and, like “White Lotus” itself, full of twists.

    “In the beginning, I totally played him for a guy who was, you know, on his last legs,” Gries said in a recent interview with CNN, referencing Greg’s very apparent ill health in the first season of “White Lotus,” which premiered to rave reviews in summer 2021. He added: “When you play a character, you want to find his empathetic side, and you want to understand where they came from, and what got them to where they are.”

    But when he was contacted by creator Mike White about appearing in Season 2, Gries realized he would have to adjust his framing of Greg, despite having previously imagined a “comprehensive history” for him on his own.

    “(White) said, ‘I’m writing it right now, and I’m writing you, and I just need to know here and now: If you’re in, I’ll continue writing. If not, I’ll stop,’” Gries recalled.

  9. Davidled表示:

    https://casinositeleri1st.com/# casino siteleri 2025

  10. I cannot thank you enough for the post.Much thanks again. Great.

  11. BradyGem表示:

    casino siteleri 2025: casino siteleri – bahis oyun siteleri casinositeleri1st.com

  12. Davidled表示:

    https://casinositeleri1st.shop/# deneme veren siteler

  13. RobertCex表示:

    lisansl? casino siteleri: casino siteleri – gГјvenilir casino bahis siteleri casinositeleri1st.com

  14. Xazrhmb表示:

    Приобрести диплом института!
    Мы изготавливаем дипломы любых профессий по выгодным ценам. Вы покупаете документ через надежную и проверенную временем фирму. : zimtechinfo.com/companies/frees-diplom

  15. GarrettMom表示:

    lisansl? casino siteleri lisansl? casino siteleri yatД±rД±m bonusu veren siteler casinositeleri1st.shop

  16. BradyGem表示:

    sweet bonanza: sweet bonanza 1st – sweet bonanza slot sweetbonanza1st.shop

  17. RobertCex表示:

    casino siteleri: casino siteleri – casino siteleri 2025 casinositeleri1st.com

  18. Cazrriw表示:

    Мы изготавливаем дипломы любых профессий по доступным тарифам. Купить диплом с реестром — kyc-diplom.com/diplom-s-reestrom.html

  19. Mazrwos表示:

    Мы готовы предложить дипломы любой профессии по невысоким тарифам. Всегда стараемся поддерживать для заказчиков адекватную ценовую политику. Важно, чтобы документы были доступными для большого количества граждан.
    Заказ документа, который подтверждает окончание института, – это грамотное решение. Приобрести диплом любого университета: 10000diplomov.ru/kupit-diplom-kolledzha-12/

  20. Weldonsib表示:

    canlД± +18: casibom guncel adres – betler casibom1st.com

  21. BradyGem表示:

    lisansl? casino siteleri: guvenilir casino siteleri – deneme bonusu veren siteler casinositeleri1st.com

  22. Weldonsib表示:

    yeni deneme bonusu veren siteler 2025: casibom giris adresi – 30 tl bonus veren bahis siteleri casibom1st.com

  23. Cazrvkk表示:

    Заказать диплом университета поспособствуем. Купить диплом бакалавра в Сочи – diplomybox.com/kupit-diplom-bakalavra-v-sochi

  24. pakistan top call girls escorts in islamabad https://www.cheapviagrausaonline.com .

  25. mostbet_pwMt表示:

    мостбет скачать бесплатно https://www.mostbet6012.ru .

  26. GarrettMom表示:

    sweet bonanza siteleri [url=https://sweetbonanza1st.shop/#]sweet bonanza oyna[/url] sweet bonanza giris sweetbonanza1st.com

  27. Weldonsib表示:

    en yeni deneme bonusu veren siteler 2025: casibom resmi – internet kumar oyunu casibom1st.com

發佈回覆給「Weldonsib」的留言 取消回覆

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