I have created a progress timer (Type bar) .I have a created a scale9sprite and set its content size to visible width.
I am using the same image file for both progress timer and scale9sprite. I want my progress timer to start from left to visible width. But my progress start from left to image width how can i do that.My sample code is -
float Abc::showTimeLeft(float height)
{
auto m_timeoutSprite=cocos2d::ui::Scale9Sprite::create("Sweep_result_white_bg.png");
m_visibleSize=Director::getInstance()->getVisibleSize();
auto label=Label::createWithSystemFont("NEW ROUND WILL START IN",
UIImagePaths::DEFAULT_FONT_NAME(),22);
m_timeoutSprite->setContentSize(cocos2d::Size(m_visibleSize.width,label->getBoundingBox().size.height*2));
auto yPos=height-m_timeoutSprite->getBoundingBox().size.height;
m_timeoutSprite->setPosition(cocos2d::Vec2(m_visibleSize.width/2,yPos));
this->addChild(m_timeoutSprite);
schedule(schedule_selector(Abc::::newRoundTimeLabelUpdate), 1.0); //here i am updating the percentage of progress Timer
auto m_timeOutProgressTimer = ProgressTimer::create(Sprite::create("Sweep_result_white_bg.png"));
if (m_timeOutProgressTimer != nullptr )
{
m_timeOutProgressTimer->setType(ProgressTimer::Type::BAR);
m_timeOutProgressTimer->setMidpoint(Vec2(0, 0.5));
m_timeOutProgressTimer->setBarChangeRate(Vec2(1, 0));
m_timeOutProgressTimer->setPercentage(0);
m_timeOutProgressTimer->setColor(cocos2d::Color3B::GREEN);
m_timeOutProgressTimer->setContentSize(Size(m_timeoutSprite->getBoundingBox().size));
m_timeOutProgressTimer->setPosition(Vec2(m_timeoutSprite->getBoundingBox().size.width/2, m_timeoutSprite->getBoundingBox().size.height/2 ));
m_timeoutSprite->addChild(m_timeOutProgressTimer);
}
auto x1=m_timeoutSprite->getBoundingBox().size;
auto x2=m_timeOutProgressTimer->getBoundingBox().size;
return yPos-m_timeoutSprite->getBoundingBox().size.height;
}