different between "sprite->getTexture()->getContentSize()" and "sprite->getContentSize()"


#1

Hi guys,
I have test in my project, i just create many CCSprites, and i found that “sprite->getTexture()>getContentSize" and "sprite>getContentSize()” always get the same CCSize.
So I am confuse that what’s different between them? and in what case, them will got the different CCSize?

Thanks in advanced!


#2

My guess is that sprite->getTexture()->getContentSize() returns the size of the texture that is used by the sprite, and sprite->getContentSize() returns the size of the sprite itself.
They are the same by default (i.e. a sprite will have the same size as its texture upon creation). But you can change the size of the sprite, which does not affect the size of the texture.
So, if you have multiple sprites that are all using the same texture, resizing one doesn’t change the size of the other sprites.


#3

Hi Hasyimi,
I think you are right.
I found this definisition:
CCSize CCTexture2D::getContentSize
{
CCSize ret;
ret.width = m_tContentSize.width / CC_CONTENT_SCALE_FACTOR;
ret.height = m_tContentSize.height / CC_CONTENT_SCALE_FACTOR;
return ret;
}

it seems that the texture can be scaled, so the “sprite->getContentSize()” should be the m_tContentSize