improve loading Bar Test

This commit is contained in:
andyque 2015-01-26 14:39:44 +08:00
parent fdbf84a118
commit 0e67cfcbff
2 changed files with 9 additions and 5 deletions

View File

@ -193,6 +193,8 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType)
barRendererScaleChangedWithSize();
updateContentSizeWithTextureSize(_barRendererTextureSize);
this->updateProgressBar();
_barRendererAdaptDirty = true;
}
@ -216,7 +218,7 @@ void LoadingBar::setScale9Enabled(bool enabled)
ignoreContentAdaptWithSize(_prevIgnoreSize);
}
setCapInsets(_capInsets);
this->setPercent(_percent);
this->updateProgressBar();
_barRendererAdaptDirty = true;
}

View File

@ -427,18 +427,19 @@ bool UILoadingBarReloadTexture::init()
LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
loadingBar->setTag(0);
loadingBar->ignoreContentAdaptWithSize(false);
loadingBar->setScale9Enabled(true);
// loadingBar->setScale9Enabled(true);
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
loadingBar->setContentSize(Size(300, 13));
loadingBar->setName("texture0");
loadingBar->setDirection(LoadingBar::Direction::RIGHT);
loadingBar->setPercent(70);
loadingBar->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f));
_uiLayer->addChild(loadingBar);
auto buttonScale9 = Button::create();
auto buttonScale9 = Button::create("cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
buttonScale9->setTitleText("ToggleScale9");
buttonScale9->addClickEventListener([=](Ref*){
loadingBar->setScale9Enabled(!loadingBar->isScale9Enabled());
@ -446,7 +447,8 @@ bool UILoadingBarReloadTexture::init()
buttonScale9->setPosition(loadingBar->getPosition() + Vec2(-50,50));
_uiLayer->addChild(buttonScale9);
auto buttonChangeTexture = Button::create();
auto buttonChangeTexture = Button::create("cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
buttonChangeTexture->setTitleText("ChangeTexture");
buttonChangeTexture->addClickEventListener([=](Ref*){
auto name = loadingBar->getName();