现在的位置: 首页 > 综合 > 正文

Cocos2d-x_CCProgressTo(进度计时器类)介绍

2016年08月30日 ⁄ 综合 ⁄ 共 839字 ⁄ 字号 评论关闭
bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCSize winSize = CCDirector::sharedDirector()->getWinSize();

    CCProgressTimer *pross = CCProgressTimer::create(CCSprite::create("Icon-57.png"));
    pross->setPosition(ccp(200, 170));
    pross->setType(kCCProgressTimerTypeRadial);  // 设置进度条样式
    pross->setPercentage(100);  // 设置进度值范围
    pross->setReverseProgress(false);  // 设置计时方向
    CCProgressTo *to1 = CCProgressTo::create(2, 100);
    this->scheduleUpdate();
    pross->runAction(CCRepeatForever::create(to1));
    this->addChild(pross);
    
    CCProgressTimer *prossR = CCProgressTimer::create(CCSprite::create("Icon-57.png"));
    prossR->setPosition(ccp(310, 170));
    prossR->setType(kCCProgressTimerTypeBar);
    prossR->setMidpoint(ccp(0, 1));
    prossR->setBarChangeRate(ccp(0, 1));
    CCProgressTo *to2 = CCProgressTo::create(2, 100);
    prossR->runAction(CCRepeatForever::create(to2));
    this->addChild(prossR);
    
    return true;
}

抱歉!评论已关闭.