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