[Cocos2d-x]-achieve Dota skill Cooling Effect

Source: Internet
Author: User
Tags addchild dota

Cocos2d-x learning exchange group: 140326755

Email:Hahayacoder@gmail.com

 

1. On csdn, I saw the cool-down effect of some Dota skills, and I was curious about how the cool-down effect was achieved. So I tried to implement it.

 

2. In fact, the principle of skill CD is very simple: Prepare two pictures, one is a dark one, put the dark picture on the ground, and the other is put on the above (note: the two pictures are of the same size, the specified image completely overwrites the hidden image.

 

3. Now that we know it, it's easy to implement. The following is a key code.

Ccsprite * coolsprite = ccsprite: Create ("cool.png"); coolsprite-> setposition (CCP (winsize. width/2, winsize. height/2 )); /** the second zorder parameter. When multiple nodes are displayed on the Z axis, the engine determines the order of the nodes based on their Z axes. The Z axis is large and will overwrite the Z axis. */This-> addchild (coolsprite, 0); ccsprite * activesprite = ccsprite: Create ("active.png"); ccprogresstimer * progresscd = ccprogresstimer: Create (activesprite ); /** set ccprogresstd type. Version 2.0 and later only retain two formats */progresscd-> settype (ccprogresstimertype: kccprogresstimertyperadial); progresscd-> setposition (CCP (winsize. width/2, winsize. height/2); // The image whose zorder is greater than the dark image will overwrite the hidden image this-> addchild (progresscd, 1 ); /** let the progress bar execute an action to show the animation effect */ccprogressto * progresstoaction = ccprogressto: Create (8.0f, 100366f); progresscd-> runaction (progresstoaction );

 

4. Running Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.