Monkey original, you are welcome to reprint, please note clearly! Thank you.
Address: http://blog.csdn.net/yanghuiliu/article/details/6917242
The most skill CD is used in the game.
One is a gray translucent transparent mask layer similar to the skill CD in Dota, Which is clockwise or counterclockwise.
The other is similar to building CD for plants in plants and botnets. Upper/lower Type mask layer.
In fact, cocos2d-x can easily achieve this effect.
Skill CD implementation in Dota:
CCProgressTimer* pt=CCProgressTimer::progressWithFile("cd.png");mPercentage=100;pt->setPercentage(mPercentage);
Cd.png is a translucent gray image. In this way, the percentage is set to 100. In this way, the CD layer is displayed and overwritten on the skill chart.
Turn the CD:
pt->setPercentage((100-mPercentage++));
OK. You can achieve this by setting the percentage value continuously.
As you can see, I reduced from 100 to 0, because the default value is 100 when the progress is full.
If you think this is unpleasant, you need to set it from 1 to 100. Alternatively, you only need to go to its source code. The file is ccprogresstimer. M. Just modify it.
Find this line of code float alpha = percentage _/100.f;
Add a piece of code below:
If (Alpha! = 0.f & Alpha! = 1.f)
{
Alpha =
1. F-alpha;
}
In this way, the truth is the same.
Skill CD implementation in Plants vs. botnets: