CCProgressTo 进度计时器

新建工程,名为testProgress

#include "HelloWorldScene.h"

#include "SimpleAudioEngine.h"


using namespace cocos2d;

using namespace CocosDenshion;


CCScene* HelloWorld::scene()

{

    // 'scene' is an autorelease object

    CCScene *scene = CCScene::create();

    

    // 'layer' is an autorelease object

    HelloWorld *layer = HelloWorld::create();


    // add layer as a child to scene

    scene->addChild(layer);


    // return the scene

    return scene;

}


// on "init" you need to initialize your instance

bool HelloWorld::init()

{

    //////////////////////////////

    // 1. super init first

    if ( !CCLayer::init() )

    {

        return false;

    }


    CCProgressTimer *pross=CCProgressTimer::create(CCSprite::create("Icon.png"));

    pross->setPosition(ccp(100,100));

    //设置进度条的样式

    pross->setType(kCCProgressTimerTypeRadial);

    //设置进度值的范围[0,100]

    pross->setPercentage(100);

    

    //反进度计时

    pross->setReverseProgress(true);

    addChild(pross);

    CCProgressTo *to1=CCProgressTo::create(2,100);

    pross->runAction(CCRepeatForever::create(to1));

    

    CCProgressTimer *prossR=CCProgressTimer::create(CCSprite::create("Icon.png"));

    prossR->setPosition(ccp(210,180));

    prossR->setType(kCCProgressTimerTypeBar);

    //设置计时器运动方向

    prossR->setMidpoint(ccp(0,1));

    //设置计时器的宽高起始比例

    prossR->setBarChangeRate(ccp(0,1));

    

    addChild(prossR);

    CCProgressTo *to2=CCProgressTo::create(2, 100);

    prossR->runAction(CCRepeatForever::create(to2));

    

    return true;

}


你可能感兴趣的:(CCProgressTo 进度计时器)