现在cocos2dx最新版本中只有两种CCProgressTimer模式
typedef enum {
/// Radial Counter-Clockwise
kCCProgressTimerTypeRadial,
/// Bar
kCCProgressTimerTypeBar,
} CCProgressTimerType;
1.创建一个CCProgressTimer
CCProgressTimer *left = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_01.png"));
2.想要达到一些效果要设置重点和增长率
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
left->setMidpoint(ccp(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
left->setBarChangeRate(ccp(1, 0));
解释下setMidpoint的参数
/**
* Midpoint is used to modify the progress start position.
* If you're using radials type then the midpoint changes the center point
* If you're using bar type the the midpoint changes the bar growth
* it expands from the center but clamps to the sprites edge so:
* you want a left to right then set the midpoint all the way to ccp(0,y)
* you want a right to left then set the midpoint all the way to ccp(1,y)
* you want a bottom to top then set the midpoint all the way to ccp(x,0)
* you want a top to bottom then set the midpoint all the way to ccp(x,1)
*/
CC_PROPERTY(CCPoint, m_tMidpoint, Midpoint);
我是这么理解:和锚点的概念有点类似,也是按照比例。(0.5,0.5)就表示中心在精灵的中间点;(0,0)则是表示起点在精灵的右下角,按照这样的规则不难理解。
而setBarChangeRete表示x,y上的增长率。
创建一些过滤效果可以通过CCProgressTo、CCProgressFromTo来创建。
CCProgressFromTo可以控制度数,更方便
//创建一个持续时间为2,从显示100%到显示0% 也就是说是从有到无
CCProgressFromTo *to2 = CCProgressFromTo::create(2, 100, 0);
初学cocos2dx,共勉!