issue #4636. finish UILoadingBar

This commit is contained in:
andyque 2014-04-03 11:34:06 +08:00
parent 278e2c3e3b
commit 48429f5738
2 changed files with 22 additions and 35 deletions

View File

@ -132,7 +132,7 @@ int LoadingBar::getDirection()
if (_scale9Enabled)
{
extension::Scale9Sprite* barRendererScale9 = static_cast<extension::Scale9Sprite*>(_barRenderer);
barRendererScale9->initWithFile(texture.c_str());
barRendererScale9->initWithFile(texture);
barRendererScale9->setCapInsets(_capInsets);
}
else
@ -144,7 +144,7 @@ int LoadingBar::getDirection()
if (_scale9Enabled)
{
extension::Scale9Sprite* barRendererScale9 = static_cast<extension::Scale9Sprite*>(_barRenderer);
barRendererScale9->initWithSpriteFrameName(texture.c_str());
barRendererScale9->initWithSpriteFrameName(texture);
barRendererScale9->setCapInsets(_capInsets);
}
else
@ -195,7 +195,7 @@ void LoadingBar::setScale9Enabled(bool enabled)
{
_barRenderer = Sprite::create();
}
loadTexture(_textureFile.c_str(),_renderBarTexType);
loadTexture(_textureFile,_renderBarTexType);
addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1);
if (_scale9Enabled)
{
@ -371,7 +371,7 @@ void LoadingBar::copySpecialProperties(Widget *widget)
{
_prevIgnoreSize = loadingBar->_prevIgnoreSize;
setScale9Enabled(loadingBar->_scale9Enabled);
loadTexture(loadingBar->_textureFile.c_str(), loadingBar->_renderBarTexType);
loadTexture(loadingBar->_textureFile, loadingBar->_renderBarTexType);
setCapInsets(loadingBar->_capInsets);
setPercent(loadingBar->_percent);
setDirection(loadingBar->_barType);

View File

@ -25,10 +25,7 @@ bool UILoadingBarTest_Left::init()
Size widgetSize = _widget->getSize();
// Add the alert
Text* alert = Text::create();
alert->setText("LoadingBar left");
alert->setFontName("fonts/Marker Felt.ttf");
alert->setFontSize(30);
Text* alert = Text::create("LoadingBar left", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
_uiLayer->addChild(alert);
@ -36,10 +33,9 @@ bool UILoadingBarTest_Left::init()
// Create the loading bar
LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
loadingBar->setTag(0);
// loadingBar->loadTexture("cocosui/sliderProgress.png");
// loadingBar->setPercent(0);
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
_uiLayer->addChild(loadingBar);
return true;
@ -107,22 +103,19 @@ bool UILoadingBarTest_Right::init()
Size widgetSize = _widget->getSize();
// Add the alert
Text *alert = Text::create();
alert->setText("LoadingBar right");
alert->setFontName("fonts/Marker Felt.ttf");
alert->setFontSize(30);
Text *alert = Text::create("LoadingBar right", "fonts/Marker Felt.ttf", 30);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
_uiLayer->addChild(alert);
// Create the loading bar
LoadingBar* loadingBar = LoadingBar::create();
LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
loadingBar->setTag(0);
loadingBar->loadTexture("cocosui/sliderProgress.png");
loadingBar->setDirection(LoadingBarTypeRight);
loadingBar->setPercent(0);
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
_uiLayer->addChild(loadingBar);
return true;
@ -190,24 +183,21 @@ bool UILoadingBarTest_Left_Scale9::init()
Size widgetSize = _widget->getSize();
// Add the alert
Text* alert = Text::create();
alert->setText("LoadingBar left scale9 render");
alert->setFontName("fonts/Marker Felt.ttf");
alert->setFontSize(20);
Text* alert = Text::create("LoadingBar left scale9 render", "fonts/Marker Felt.ttf", 20);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
_uiLayer->addChild(alert);
// Create the loading bar
LoadingBar* loadingBar = LoadingBar::create();
LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
loadingBar->setTag(0);
loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
loadingBar->setScale9Enabled(true);
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
loadingBar->setPercent(0);
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
_uiLayer->addChild(loadingBar);
return true;
@ -275,25 +265,22 @@ bool UILoadingBarTest_Right_Scale9::init()
Size widgetSize = _widget->getSize();
// Add the alert
Text *alert = Text::create();
alert->setText("LoadingBar right scale9 render");
alert->setFontName("fonts/Marker Felt.ttf");
alert->setFontSize(20);
Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
_uiLayer->addChild(alert);
// Create the loading bar
LoadingBar* loadingBar = LoadingBar::create();
LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
loadingBar->setTag(0);
loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
loadingBar->setScale9Enabled(true);
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
loadingBar->setDirection(LoadingBarTypeRight);
loadingBar->setPercent(0);
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
_uiLayer->addChild(loadingBar);
return true;