problem with CCSprite::setTexture

problem with CCSprite::setTexture
0.0 0


This is my code:
mTexture = CCTextureCache::sharedTextureCache()->addImage(“TestTexture.png”);
CCSprite *netCastSprite = CCSprite::spriteWithTexture(mTexture);

It’s all right in iPhone simulator4.2,but crash in iPad device 。 I find it crash at “texture->retain()” of CCSprite::setTexture function。

XCode: 3.2.5 IOS: 4.2 iPad System: 4.2.1


Briefly. use CCSprite *netCastSprite = CCSprite::SpriteWithFile(“TestTexture.png”) instead, this image will also be cached in CCTextureCache.
I will test your code soon


Yes,it’s right to use CCSprite::spriteWithFile and I use CCSprite::setTextureRect instead of CCSprite::setTexture.:smiley:


Well, I just test this case, but it works well on my ipad.
My environment:
* ipad1, ios version 4.2.1
* xcode 3.2.6
* cocos2d-x 0.8.1

I create a cocos2d-x new project from template. In HelloWorldScene.cpp, I replace

CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");


CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage("HelloWorld.png");
CCSprite* pSprite = CCSprite::spriteWithTexture(pTexture);

It works well on both iphone/ipad simulator & ipad 4.2.1 device.

If you insist on fixing this case, would you please kindly write a unit test code to reproduce this crash?