I have an application that takes a screenshot of a scene and saves it to a file. I have this working and the application is on the store. Today, I have downloaded iOS 6 and the method I am using is not working anymore. I tested all I know to make it work, googled around and found this:
http://www.cocos2d-iphone.org/forum/topic/37809?replies=22#post-180983
Users seem to agree that this is working on iOS 5, but I have tested this on iOS 6 and it is producing black screenshots.
I am not a specialist in Cocos2D so, I cannot say exactly what is wrong with this guy's code. the author has a sample project on github and even his project is producing black screenshots on iOS 6.
Any clues? Thanks.
thanks
I am not sure what the GitHub version does but this code will take a screenshot and I just tested it on iOS 6 and it works fine.
+(UIImage*) screenshotWithStartNode:(CCNode*)startNode
{
[CCDirector sharedDirector].nextDeltaTimeZero = YES;
CGSize winSize = [CCDirector sharedDirector].winSize;
CCRenderTexture* rtx =
[CCRenderTexture renderTextureWithWidth:winSize.width
height:winSize.height];
[rtx begin];
[startNode visit];
[rtx end];
return [rtx getUIImage];
}
You can call it like this
CCScene *scene = [[CCDirector sharedDirector] runningScene];
CCNode *n = [scene.children objectAtIndex:0];
UIImage *img = [AppController screenshotWithStartNode:n];