Is this a bug for CCSprite?

I create a CCSprite, but I want to set its texture then.I write the code like below:

CCSprite sprite=CCSprite::create;
……
sprite~~>setTexture;
Unfortunetly, the sprite will not be displayed on screen even I explicitly call sprite~~>setVisible,but when I write code like below,the sprite will be displayed:
CCSprite
sprite=CCSprite::createWithTexture(stubTexture);
……
sprite->setTexture(myTexture);

I just don’t know why should I assign an initial texture when creating a sprite if I want to reset its texture then and let it be displayed? is this a bug for sprite?:slight_smile:

Well, it’s a bit tricky. The code below works for you

CCSprite* pSprite = CCSprite::create();
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("HelloWorld.png");
pSprite->setTexture(texture);

CCRect rect = CCRectZero;
rect.size = texture->getContentSize();
pSprite->setContentSize(rect.size);
pSprite->setTextureRect(rect);

You should set ContentSize & TextureRect properly.