Merge pull request #49 from WenhaiLin/master

Bug fix
This commit is contained in:
Wenhai Lin
2016-04-28 23:40:18 +08:00
3 changed files with 10 additions and 9 deletions
+1 -3
View File
@@ -107,9 +107,7 @@ bool ClippingNode::init()
bool ClippingNode::init(Node *stencil)
{
CC_SAFE_RELEASE(_stencil);
_stencil = stencil;
CC_SAFE_RETAIN(_stencil);
setStencil(stencil);
return true;
}
+5 -5
View File
@@ -144,7 +144,7 @@ Sprite* Sprite::create()
bool Sprite::init()
{
return initWithTexture(nullptr, Rect::ZERO );
return initWithTexture(nullptr, Rect::ZERO, false);
}
bool Sprite::initWithTexture(Texture2D *texture)
@@ -158,7 +158,7 @@ bool Sprite::initWithTexture(Texture2D *texture)
Rect rect = Rect::ZERO;
rect.size = texture->getContentSize();
return initWithTexture(texture, rect);
return initWithTexture(texture, rect, false);
}
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect)
@@ -175,7 +175,7 @@ bool Sprite::initWithFile(const std::string& filename)
{
Rect rect = Rect::ZERO;
rect.size = texture->getContentSize();
return initWithTexture(texture, rect);
return initWithTexture(texture, rect, false);
}
return false;
@@ -188,7 +188,7 @@ bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
Texture2D *texture = _director->getTextureCache()->addImage(filename);
if (texture)
{
return initWithTexture(texture, rect);
return initWithTexture(texture, rect, false);
}
return false;
@@ -336,7 +336,7 @@ void Sprite::setTexture(const std::string &filename)
Texture2D *texture = _director->getTextureCache()->addImage(filename);
setTexture(texture);
_unflippedOffsetPositionFromCenter = Vec2::ZERO;
Rect rect = Rect::ZERO;
if (texture)
rect.size = texture->getContentSize();
+4 -1
View File
@@ -158,15 +158,18 @@ void ImageView::setTextureRect(const Rect &rect)
else
{
auto sprite = _imageRenderer->getSprite();
_imageRenderer->setScale9Enabled(false);
if (sprite)
{
sprite->setTextureRect(rect);
setupTexture();
}
else
{
CCLOG("Warning!! you should load texture before set the texture's rect!");
}
_imageRenderer->setContentSize(rect.size);
setupTexture();
}
}