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