mirror of https://github.com/axmolengine/axmol.git
Fixed bugs
This commit is contained in:
parent
495e574f44
commit
b2da9d2da5
|
@ -219,30 +219,16 @@ void LoadingBar::setPercent(int percent)
|
||||||
_percent = percent;
|
_percent = percent;
|
||||||
float res = _percent/100.0;
|
float res = _percent/100.0;
|
||||||
|
|
||||||
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)
|
if (_scale9Enabled)
|
||||||
{
|
{
|
||||||
setScale9Scale();
|
setScale9Scale();
|
||||||
}
|
}
|
||||||
else
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,8 @@ void Slider::setPercent(int percent)
|
||||||
percent = 0;
|
percent = 0;
|
||||||
}
|
}
|
||||||
_percent = percent;
|
_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));
|
_slidBallRenderer->setPosition(Point(-_barLength/2.0f + dis, 0.0f));
|
||||||
if (_scale9Enabled)
|
if (_scale9Enabled)
|
||||||
{
|
{
|
||||||
|
@ -347,24 +348,10 @@ void Slider::setPercent(int percent)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int x = 0, y = 0;
|
Sprite* spriteRenderer = static_cast<Sprite*>(_progressBarRenderer);
|
||||||
switch (_progressBarTexType)
|
Rect rect = spriteRenderer->getTextureRect();
|
||||||
{
|
rect.size.width = _progressBarTextureSize.width * res;
|
||||||
case UI_TEX_TYPE_PLIST:
|
spriteRenderer->setTextureRect(rect, spriteRenderer->isTextureRectRotated(), rect.size);
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue