fix a small bug related to non slice anchorPoint

This commit is contained in:
zilongshanren 2015-10-29 14:27:27 +08:00
parent ccf4cb5a74
commit 9a14ad5b14
1 changed files with 20 additions and 25 deletions

View File

@ -49,9 +49,9 @@ namespace ui {
,_flippedY(false)
,_isPatch9(false)
,_brightState(State::NORMAL)
,_nonSliceSpriteAnchor(Vec2::ANCHOR_MIDDLE)
,_sliceVertices(nullptr)
,_sliceIndices(nullptr)
,_nonSliceSpriteAnchor(Vec2::ANCHOR_MIDDLE)
{
this->setAnchorPoint(Vec2(0.5,0.5));
}
@ -138,6 +138,7 @@ namespace ui {
const Size &originalSize,
const Rect& capInsets)
{
bool ret = true;
if(sprite)
{
auto texture = sprite->getTexture();
@ -158,15 +159,15 @@ namespace ui {
}
}
this->updateWithSprite(sprite,
rect,
rotated,
offset,
originalSize,
actualCapInsets);
ret = this->updateWithSprite(sprite,
rect,
rotated,
offset,
originalSize,
actualCapInsets);
}
return true;
return ret;
}
bool Scale9Sprite::initWithBatchNode(cocos2d::SpriteBatchNode *batchnode,
@ -391,6 +392,7 @@ namespace ui {
const Size &originalSize,
const Rect& capInsets)
{
GLubyte opacity = getOpacity();
Color3B color = getColor();
@ -421,15 +423,6 @@ namespace ui {
{
return false;
}
_scale9Image->setAnchorPoint(Vec2::ZERO);
_scale9Image->setPosition(Vec2::ZERO);
SpriteFrame *spriteFrame = _scale9Image->getSpriteFrame();
if (!spriteFrame)
{
return false;
}
Rect rect(textureRect);
Size size(originalSize);
@ -458,6 +451,8 @@ namespace ui {
if (_scale9Enabled)
{
_scale9Image->setAnchorPoint(Vec2::ZERO);
_scale9Image->setPosition(Vec2::ZERO);
this->createSlicedSprites();
}