Merge pull request #4709 from nutty898/develop_nutty_modify_framework_texturebugfixed

Develop nutty modify framework texturebugfixed
This commit is contained in:
James Chen 2013-12-27 02:33:31 -08:00
commit 65cc2d38b2
2 changed files with 12 additions and 39 deletions

View File

@ -217,32 +217,18 @@ void LoadingBar::setPercent(int percent)
return;
}
_percent = percent;
float res = _percent/100.0;
float res = _percent / 100.0f;
int x = 0, y = 0;
switch (_renderBarTexType)
{
case UI_TEX_TYPE_PLIST:
{
Sprite* barNode = dynamic_cast<Sprite*>(_barRenderer);
if (barNode)
{
Point to = barNode->getTextureRect().origin;
x = to.x;
y = to.y;
}
break;
}
default:
break;
}
if (_scale9Enabled)
{
setScale9Scale();
}
else
{
static_cast<Sprite*>(_barRenderer)->setTextureRect(Rect(x, y, _barRendererTextureSize.width * res, _barRendererTextureSize.height));
Sprite* spriteRenderer = static_cast<Sprite*>(_barRenderer);
Rect rect = spriteRenderer->getTextureRect();
rect.size.width = _barRendererTextureSize.width * res;
spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size);
}
}
@ -324,7 +310,7 @@ void LoadingBar::barRendererScaleChangedWithSize()
void LoadingBar::setScale9Scale()
{
float width = (float)(_percent) / 100 * _totalLength;
float width = (float)(_percent) / 100.0f * _totalLength;
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _size.height));
}

View File

@ -339,7 +339,8 @@ void Slider::setPercent(int percent)
percent = 0;
}
_percent = percent;
float dis = _barLength*(percent/100.0f);
float res = percent / 100.0f;
float dis = _barLength * res;
_slidBallRenderer->setPosition(Point(-_barLength/2.0f + dis, 0.0f));
if (_scale9Enabled)
{
@ -347,24 +348,10 @@ void Slider::setPercent(int percent)
}
else
{
int x = 0, y = 0;
switch (_progressBarTexType)
{
case UI_TEX_TYPE_PLIST:
{
Sprite* barNode = dynamic_cast<Sprite*>(_progressBarRenderer);
if (barNode)
{
Point to = barNode->getTextureRect().origin;
x = to.x;
y = to.y;
}
break;
}
default:
break;
}
static_cast<Sprite*>(_progressBarRenderer)->setTextureRect(Rect(x, y, _progressBarTextureSize.width * (percent/100.0f), _progressBarTextureSize.height));
Sprite* spriteRenderer = static_cast<Sprite*>(_progressBarRenderer);
Rect rect = spriteRenderer->getTextureRect();
rect.size.width = _progressBarTextureSize.width * res;
spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size);
}
}