I have a method that splits a UIImage and returns the sections of the image as an array:
- (NSMutableArray *) splitImage:(UIImage *)image;
But I need to split a Cocos2d sprite in half. How can I get the UIImage from of the sprite?
The closest thing I can find is the sprite’s CCTexture2D, but I still can’t get to the UIImage.
Unfortunately, CCTextureCache doesn’t retain any images (UIImage, PNG, JPEG and so forth) when it instantiates CCTexture2D. It uses glTexImage2D or glCompressedTexImage2D to create OpenGL ES texture with image data, however the application can’t access the pixel data of the texture. And CCTexture2D doesn’t retain any images as well.
Thus, you have to retain UIImage instance for CCTexture2D that is used from CCSprite.