about dynamically change sprite texture, some bug?

hi,

I want to dynamically change my ccsprite object’s texture. So i code as below:

CCSprite sp = CCSprite::spriteWithFile;
sp~~>setPosition);
this~~>addChild;
CCTexture2D
tex = CCTextureCatch::sharedTextureCatch()>addImage;
sp
>setContentSize(tex~~>getContentSize);
sp~~>setTexture(tex);

but, i found the sp2.png size is larger than i want,
i want to know why?

some guys can help me ?

thank you!

You should invoke setTextureRect to set texture size.