mirror of https://github.com/axmolengine/axmol.git
Set Sprite rect properly when create with empty texture.
This commit is contained in:
parent
beb593a22a
commit
f16748f735
|
@ -279,7 +279,15 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
||||||
|
|
||||||
// update texture (calls updateBlendFunc)
|
// update texture (calls updateBlendFunc)
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
setTextureRect(rect, rotated, rect.size);
|
if (texture)
|
||||||
|
{
|
||||||
|
setTextureRect(rect, rotated, rect.size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Rect defaultRect{0.f, 0.f, static_cast<float>(_texture->getPixelsWide()), static_cast<float>(_texture->getPixelsHigh())};
|
||||||
|
setTextureRect(defaultRect, false, defaultRect.size);
|
||||||
|
}
|
||||||
|
|
||||||
// by default use "Self Render".
|
// by default use "Self Render".
|
||||||
// if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render"
|
// if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render"
|
||||||
|
|
Loading…
Reference in New Issue