写一个进度条~~

1.void GameScene::setProgress(){
    
pr=ProgressTimer::create(Sprite::create("progress.png"));

                pr->setType(kCCProgressTimerTypeBar);  //类型
pr->setPosition(ccp(320,1000));


   pr->setMidpoint(ccp(0,0));         //进度动画放下


pr->setBarChangeRate(ccp(1,0));       //进度条宽高的变化
pr->setPercentage(100);
this->addChild(pr,1);
numsTTF=CCLabelTTF::create("0", "Marker Felt", 18);  




numsTTF->setPosition(ccp(300, 1000));  




this->addChild(numsTTF, 1);  




this->scheduleUpdate();  
}
void GameScene::update(float dt){
float cu=pr->getPercentage();
cu-=0.08f;
if(cu<=0){
Director::getInstance()->replaceScene(TransitionProgressRadialCCW::create(2.0f,GameOverLayer::scene()));
}
pr->setPercentage(cu);
CCString *str = CCString::createWithFormat("%.2f%%",cu);  


numsTTF->setString(str->getCString());  
}

你可能感兴趣的:(写一个进度条~~)