Fixed Height Progress Bar?

Fixed Height Progress Bar?
0.0 0


Hi everyone, I’m new here. I am experimenting with progress bars and it seems that cocos2d-x doesn’t have a lot of the same progress timer types that cocos2d-iphone has. Currently my code is this:

Layer Init
CCSprite *sp = CCSprite::spriteWithFile("Images/UI/loadbar.png"); loadingBar = CCProgressTimer::progressWithSprite(sp); loadingBar->setType(CCProgressTimerType::kCCProgressTimerTypeBar); loadingBar->setAnchorPoint(ccp(0,0)); loadingBar->setPositionX(size.width - sp->getContentSize().width); loadingBar->setMidpoint(ccp(0,0));

Step Function
CCProgressTo *progressTo = CCProgressTo::actionWithDuration(0.5f,100); loadingBar->runAction(progressTo);

However, this causes my loading bar image to scale to full size, rather than appearing form left to right. How would you accomplish this in cocos2d-x?


I found the answer. You have to include this line to make the bar height already 100% done when it’s animating.