sf::Sprite::setTexture(..., false) resets the texture rect only if it hasn't been set before
This commit is contained in:
parent
1d80eaa59b
commit
692240f60d
@ -36,7 +36,7 @@ namespace sf
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Sprite::Sprite() :
|
Sprite::Sprite() :
|
||||||
m_texture (NULL),
|
m_texture (NULL),
|
||||||
m_textureRect(0, 0, 0, 0)
|
m_textureRect()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ m_textureRect(0, 0, 0, 0)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Sprite::Sprite(const Texture& texture) :
|
Sprite::Sprite(const Texture& texture) :
|
||||||
m_texture (NULL),
|
m_texture (NULL),
|
||||||
m_textureRect(0, 0, 0, 0)
|
m_textureRect()
|
||||||
{
|
{
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ m_textureRect(0, 0, 0, 0)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Sprite::Sprite(const Texture& texture, const IntRect& rectangle) :
|
Sprite::Sprite(const Texture& texture, const IntRect& rectangle) :
|
||||||
m_texture (NULL),
|
m_texture (NULL),
|
||||||
m_textureRect(0, 0, 0, 0)
|
m_textureRect()
|
||||||
{
|
{
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
setTextureRect(rectangle);
|
setTextureRect(rectangle);
|
||||||
@ -63,8 +63,8 @@ m_textureRect(0, 0, 0, 0)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Sprite::setTexture(const Texture& texture, bool resetRect)
|
void Sprite::setTexture(const Texture& texture, bool resetRect)
|
||||||
{
|
{
|
||||||
// Recompute the texture area if requested, or if there was no valid texture before
|
// Recompute the texture area if requested, or if there was no valid texture & rect before
|
||||||
if (resetRect || !m_texture)
|
if (resetRect || (!m_texture && (m_textureRect == sf::IntRect())))
|
||||||
setTextureRect(IntRect(0, 0, texture.getSize().x, texture.getSize().y));
|
setTextureRect(IntRect(0, 0, texture.getSize().x, texture.getSize().y));
|
||||||
|
|
||||||
// Assign the new texture
|
// Assign the new texture
|
||||||
|
Loading…
Reference in New Issue
Block a user