mirror of https://github.com/axmolengine/axmol.git
add null pointer check, make code more robust
This commit is contained in:
parent
f3e9af8100
commit
1bb60ab4bb
|
@ -101,15 +101,25 @@ void LoadingBar::setDirection(cocos2d::ui::LoadingBar::Direction direction)
|
|||
case Direction::LEFT:
|
||||
_barRenderer->setAnchorPoint(Vec2(0.0f,0.5f));
|
||||
_barRenderer->setPosition(Vec2(0,_contentSize.height*0.5f));
|
||||
if (!_scale9Enabled) {
|
||||
_barRenderer->getSprite()->setFlippedX(false);
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
auto innerSprite = _barRenderer->getSprite();
|
||||
if (nullptr != innerSprite)
|
||||
{
|
||||
innerSprite->setFlippedX(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
_barRenderer->setAnchorPoint(Vec2(1.0f,0.5f));
|
||||
_barRenderer->setPosition(Vec2(_totalLength,_contentSize.height*0.5f));
|
||||
if (!_scale9Enabled) {
|
||||
_barRenderer->getSprite()->setFlippedX(true);
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
auto innerSprite = _barRenderer->getSprite();
|
||||
if (nullptr != innerSprite)
|
||||
{
|
||||
innerSprite->setFlippedX(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -148,14 +158,24 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType)
|
|||
{
|
||||
case Direction::LEFT:
|
||||
_barRenderer->setAnchorPoint(Vec2(0.0f,0.5f));
|
||||
if (!_scale9Enabled) {
|
||||
_barRenderer->getSprite()->setFlippedX(false);
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
auto innerSprite = _barRenderer->getSprite();
|
||||
if (nullptr != innerSprite)
|
||||
{
|
||||
innerSprite->setFlippedX(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Direction::RIGHT:
|
||||
_barRenderer->setAnchorPoint(Vec2(1.0f,0.5f));
|
||||
if (!_scale9Enabled) {
|
||||
_barRenderer->getSprite()->setFlippedX(true);
|
||||
if (!_scale9Enabled)
|
||||
{
|
||||
auto innerSprite = _barRenderer->getSprite();
|
||||
if (nullptr != innerSprite)
|
||||
{
|
||||
innerSprite->setFlippedX(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue