I’m downloading image file from the internet and using this file to create new texture with addImage function. CCTexture2D *newTexture = CCTextureCache::sharedTextureCache()->addImage(sFileName.c_str());
But sometimes file is not valid image (e.g. text or html). In that case addImage causes crash. Try-catch block does not help. So, my question is:
Hi Alexander,
Working with CCSprite there are several init funtions that returns a bool, that allows you to check if initialization is right before working with it.
I’ve seen that CCTexture2D also has init functions, though CCTextureCache doesn’t.
Good! Try checking “text.jpg” without changing content of the file. Most likely it will crash. But thank you for info! I will double check my sources and will try initWithFile, it’s possible that I have missed something.