CCProgressTimer进度条

cocos2d-x提供了CCProgressTimer类,可以方便地实现进度条的功能,从cocos2d-x 2.x版本以后将ProgressTimer的类型减少为两种:

typedef enum {
    /// Radial Counter-Clockwise
    kCCProgressTimerTypeRadial,
    /// Bar
    kCCProgressTimerTypeBar,
} CCProgressTimerType;
下面是一个应用例子(设置游戏速度大小,BG.png为背景图,Top.png为进度条,两图大小相同),通过m_pMenuSpeed>setPercentage(float persentage)可以改变纹理显示的长度,以此来设置速度。

m_pSpeedBG = CCSprite::create("BG.png");

m_pSpeedBG->setPosition(ccp(mScreenSize.width * 0.5f, 494));
m_pConfigureNode->addChild(m_pSpeedBG);


m_pMenuSpeed = CCProgressTimer::create(CCSprite::create("Top.png"));
m_pMenuSpeed->setType(kCCProgressTimerTypeBar);// 设置进度条的类型为条形
m_pMenuSpeed->setMidpoint(ccp(0,0.5));// 设置开始展示点的位置,动画开始的起始点   
m_pMenuSpeed->setAnchorPoint(ccp(0.0f,0.5f));
m_pMenuSpeed->setBarChangeRate(ccp(1, 0));// 设置进度条变化方向
m_pMenuSpeed->setPosition(ccp(0,m_pMenuSpeed->getContentSize().height * 0.5f));
m_pMenuSpeed->setPercentage(m_nSpeedPoint * 5);// 设置初始百分比的值

m_pSpeedBG->addChild(m_pMenuSpeed);

图Top.png


参考:

http://www.tuicool.com/articles/BvM3Yf

http://blog.csdn.net/somestill/article/details/9406501

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值