Skip to content

Instantly share code, notes, and snippets.

@syuhari
Created January 30, 2013 06:10
Show Gist options
  • Save syuhari/4671122 to your computer and use it in GitHub Desktop.
Save syuhari/4671122 to your computer and use it in GitHub Desktop.
Cocos2d-x CCProgressTimer
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* sprite = CCSprite::create("Icon-72.png");
CCProgressTimer* timer = CCProgressTimer::create(sprite);
timer->setType(kCCProgressTimerTypeRadial);
timer->setPosition(ccp(size.width/2, size.height/2));
timer->setPercentage(0.0f);
this->addChild(timer, 1, 1);
this->scheduleUpdate();
return true;
}
void HelloWorld::update(float delta) {
CCProgressTimer* timer = (CCProgressTimer*)this->getChildByTag(1);
float percent = timer->getPercentage();
percent += 10.0f * delta;
timer->setPercentage(percent);
if (percent>100.0f) {
this->unscheduleUpdate();
}
}
@diamond94618
Copy link

Thank you very much for your good posting

@niralikhunt
Copy link

thnks it's very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment