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

18,707 Responses

  1. Introducing to you the most prestigious online entertainment address today. Visit now to experience now!

  2. вывод из запоя дешево ростов-на-дону вывод из запоя дешево ростов-на-дону .

  3. рейтинг процессоров для игр topcpu.ru .

  4. прокапаться на дому от алкоголя цена прокапаться на дому от алкоголя цена .

  5. нарколог на дому капельница цена нарколог на дому капельница цена .

  6. On-balance volume – the momentum of buying and selling stocks.

  7. Throughout coaching, each recruit’s pure skills will be honed, and they will be skilled in a specialty (more on that on the following page).

  8. As we speak, reactive dyes are the commonest.

  9. Lebanon County Special Olympics.

  10. рейтинг игровых процессоров http://www.topcpu.ru/ .

  11. прокапаться от алкоголя на дому прокапаться от алкоголя на дому .

  12. Charlesbot表示:

    https://fastpillseasy.com/# top rated ed pills

  13. Wilbertacild表示:

    Understanding Convex Finance
    Convex Finance is an innovative platform designed to enhance yield farming in the decentralized finance (DeFi) space. It allows users to maximize their rewards without the need for technical expertise.

    What is Convex Finance?
    Convex Finance is a DeFi platform that builds on top of , optimizing the way liquidity providers and stakers can earn rewards. By using Convex, users can increase the efficiency and profitability of their investments.
    convex finance
    Key Features of Convex Finance
    Enhanced Rewards: Users can earn boosted rewards on their staked assets by utilizing the Convex platform.
    Decentralized and Secure: Built on top of the existing Curve protocol, ensuring a high level of trust and security.
    User-Friendly Interface: Designed to be easy for both new and experienced DeFi users to navigate.
    Why Choose Convex Finance?
    There are several compelling reasons to choose Convex Finance for your yield farming needs. Whether you’re new to DeFi or an experienced investor, Convex offers unique benefits:

    Higher Yields: By pooling your resources, Convex helps maximize the potential returns on your investments.
    Gas Fee Efficiency: Transactions through Convex are optimized to reduce costs, making it a more efficient choice.
    Community-Driven: Convex evolves based on user feedback, ensuring that the platform continues to meet the needs of its community.
    Getting Started with Convex Finance
    Starting with Convex Finance is straightforward:

    Visit the .
    Connect your compatible crypto wallet.
    Select the pools you want to stake in and boost your earnings.
    For more detailed instructions, referring to the section will provide deeper insights and troubleshooting support.

    Conclusion
    Convex Finance revolutionizes the way users interact with DeFi, offering enhanced yields while maintaining a focus on security and simplicity. By leveraging the capabilities of Convex, investors can confidently optimize their yield farming strategies.

    Boost Your Earnings with Convex Finance Staking
    Are you looking to maximize your returns on cryptocurrency investments? Discover the potential of Convex Finance Staking today. This innovative platform offers you the opportunity to earn more by staking popular tokens like CRV, achieving enhanced yields while gaining additional benefits.

    What is Convex Finance?
    is a cutting-edge decentralized finance (DeFi) protocol that optimizes returns for Curve Finance users. It allows liquidity providers and CRV stakers to earn trading fees, boosted CRV, and take part in Convex liquidity mining.

    Why Choose Convex Staking?
    Here’s why Convex Finance should be your go-to platform for staking:

    Boosted Yields: Earn higher returns by leveraging your CRV tokens and engaging in liquidity mining.
    No Withdrawal Fees: Enjoy the flexibility to withdraw your funds without incurring additional costs.
    Rewards and Bonuses: Benefit from various incentives, including platform rewards and additional bonuses for loyal stakers.
    How to Start Staking on Convex Finance
    Follow these simple steps to start maximizing your crypto profits with Convex Finance:

    Connect Your Wallet: Use a compatible wallet like MetaMask to link your account to the platform.
    Stake Your CRV: Deposit your CRV tokens into Convex to start earning boosted rewards.
    Claim Your Rewards: Monitor your earnings and claim your rewards at your convenience.
    Explore More Benefits
    Aside from staking, Convex Finance offers a unique opportunity to participate in liquidity pools and yield farming initiatives. These options provide you with multiple avenues to enhance your total returns on investments.

    Start Staking Today
    Visit the official website to learn more about which pools and strategies offer the best returns. Take action today and secure your financial future with Convex Finance’s powerful staking solutions.

    Understanding Convex Finance: Boost Your DeFi Earnings
    As decentralized finance (DeFi) continues to grow, Convex Finance emerges as a powerful tool for users looking to optimize their Curve Finance (CRV) earnings. Whether you’re a seasoned crypto enthusiast or a newcomer, understanding how Convex Finance works can significantly enhance your income from DeFi investments.

    What is Convex Finance?
    Convex Finance is a platform that allows liquidity providers (LPs) and CRV stakers to earn higher returns without locking CRV. It achieves this by leveraging specific tokenomics to maximize yield earnings for users, while simplifying the staking process.

    How Convex Finance Works
    Here’s a breakdown of how Convex Finance operates:

    Increased Yield: Convex offers LPs additional rewards on top of the incentives already provided by Curve Finance. This maximizes your DeFi returns.
    Platform Flexibility: Unlike traditional staking, Convex Finance enables users to stake either LP tokens or CRVs without enduring long lock-up periods.
    Reward Distribution: Participants earn not just from Curve rewards but also receive a share of fees distributed by the platform, further increasing potential earnings.
    Benefits of Using Convex Finance
    There are several reasons to consider using Convex Finance:

    Efficient Yield Optimization: Convex Finance combines yields from multiple sources, providing a streamlined way for users to maximize their earnings.
    Lower Commitment: Users can earn rewards without the need for long lock-up periods, maintaining greater liquidity and flexibility.
    Community Support: With an active community and ongoing development, Convex Finance regularly updates its platform features to ensure high performance and security.
    Getting Started with Convex Finance
    To begin using Convex, you’ll need to connect a compatible crypto wallet and deposit your Curve LP tokens. Once connected, you can decide on the best strategy for your investment needs, benefiting from the enhanced yields available on this innovative DeFi platform.

    Overall, Convex Finance represents an evolving landscape in decentralized finance, offering a compelling option for maximizing CRV earnings with minimal staking constraints. Explore this platform to leverage its full potential and take advantage of the thriving DeFi ecosystem.

  14. LarryNem表示:

    Desyn Protocol
    The Desyn Protocol: An Overview
    The Desyn Protocol is a cutting-edge framework designed to enhance blockchain technology by offering a scalable and more secure ecosystem. As the demand for decentralized applications grows, the need for efficient protocols becomes crucial. Desyn addresses these needs with a unique approach, providing developers and organizations with the tools to build and manage decentralized systems with enhanced capabilities.
    desyn protocol
    Core Features of Desyn Protocol
    Scalability: The protocol integrates advanced scalability solutions, allowing for increased transaction throughput and reduced latency.
    Security: By utilizing state-of-the-art cryptography, Desyn ensures that transactional integrity and data protection are maintained.
    Flexibility: Desyn’s modular architecture enables seamless adaptability to various use cases in the blockchain sector.
    Applications and Benefits
    The Desyn Protocol is versatile, finding applications across different sectors that require blockchain solutions. In finance, it aids in creating smart contracts that bring efficiency and transparency to financial transactions. In supply chain management, Desyn can enhance traceability and accountability from production to distribution. The healthcare industry benefits from secure, immutable record keeping, ensuring both data integrity and patient privacy.

    With its emphasis on scalability and security, Desyn reduces resource consumption while optimizing performance, thus driving down operational costs. The flexibility of its architecture supports rapid deployment and integration with existing systems, providing a strategic advantage to businesses looking to transform digitally.

    Moreover, developers benefit from the open-source nature of the protocol, which encourages community involvement and continuous innovation. Desyn’s approach promises to lower barriers to entry for startups and established companies alike, fostering a vibrant ecosystem of development.

    Conclusion
    In conclusion, the Desyn Protocol represents a significant advancement in blockchain technology by combining scalability, security, and flexibility. Its wide range of applications and benefits make it a preferred choice for various industries seeking to leverage blockchain’s transformative power. As the landscape of decentralized technology evolves, Desyn is poised to play a pivotal role, offering solutions that are innovative, efficient, and secure. The protocol’s commitment to enhancing user experience and enabling strategic growth makes it a valuable asset in the digital transformation journey.

  15. капельница от запоя цена [url=https://vyvod-iz-zapoya-rostov239.ru/]капельница от запоя цена[/url] .

  16. Предлагаем услуги профессиональных инженеров офицальной мастерской.
    Еслли вы искали ремонт кофемашин melitta рядом, можете посмотреть на сайте: ремонт кофемашин melitta цены
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  17. VincentRop表示:

    Welcome to DeFiLlama: The DeFi Data Powerhouse
    In the ever-evolving world of decentralized finance, staying informed is crucial. DeFiLlama stands out as a comprehensive platform offering in-depth analytics and insights into the DeFi ecosystem. Whether you’re a seasoned investor or new to DeFi, DeFiLlama provides the tools and data you need to make informed decisions.
    [url=https://www-defliama.com]defillama app[/url]
    Why Choose DeFiLlama?
    DeFiLlama excels in delivering unbiased, reliable data that the crypto community can trust. Here’s why it’s a favorite among DeFi enthusiasts:

    Complete Transparency: DeFiLlama offers an open data approach, ensuring transparency and accuracy in all metrics provided.
    Extensive Coverage: With data on a wide array of DeFi protocols, it provides the most comprehensive DeFi analytics available.
    User-Friendly Interface: Navigate easily through DeFiLlama’s clear layout and access the data you need quickly.
    Regular Updates: Stay current with frequent updates, delivering the latest DeFi data.
    Explore Key Features
    Total Value Locked (TVL): One of the most important metrics in the DeFi space, TVL indicates the amount of assets locked in DeFi protocols. DeFiLlama tracks TVL across multiple chains, providing a comprehensive view of where value is being generated.

    Protocol Rankings: Discover which DeFi protocols are leading the pack. DeFiLlama’s rankings help you track the top-performing projects across various chains.

    Chain Analysis: Beyond individual protocols, DeFiLlama offers insights into how different blockchain networks compare in terms of ecosystem growth and performance.

    Community and Collaboration
    DeFiLlama believes in the power of community feedback and collaboration. They continuously improve their offerings based on community input, ensuring the platform meets the evolving needs of its users.

    Join the growing community of DeFi enthusiasts who trust DeFiLlama for their data needs.

    Start Your DeFi Journey Today
    Whether you’re new to DeFi or looking to deepen your understanding, DeFiLlama is your go-to resource for data that helps drive decisions. Dive into the world of decentralized finance with all the information you need at your fingertips.

    Visit today and explore the future of finance!

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

  19. вывод из запоя на дому ростов на дону вывод из запоя на дому ростов на дону .

  20. Donaldabula表示:

    what is the cheapest ed medication FastPillsEasy ed treatments online

發佈留言

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